vaibhavk1992 commented on code in PR #729: URL: https://github.com/apache/incubator-xtable/pull/729#discussion_r2559840656
########## xtable-core/src/main/java/org/apache/xtable/kernel/DeltaKernelTableExtractor.java: ########## @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.xtable.kernel; + +import java.time.Instant; +import java.util.List; +import java.util.stream.Collectors; + +import lombok.Builder; + +import io.delta.kernel.*; +import io.delta.kernel.engine.Engine; +import io.delta.kernel.types.StructField; +import io.delta.kernel.types.StructType; + +import org.apache.xtable.model.InternalTable; +import org.apache.xtable.model.schema.InternalPartitionField; +import org.apache.xtable.model.schema.InternalSchema; +import org.apache.xtable.model.storage.DataLayoutStrategy; +import org.apache.xtable.model.storage.TableFormat; + +/** + * Extracts {@link InternalTable} canonical representation of a table at a point in time for Delta. + */ +@Builder +public class DeltaKernelTableExtractor { + @Builder.Default + private static final DeltaKernelSchemaExtractor schemaExtractor = + DeltaKernelSchemaExtractor.getInstance(); + + private final String basePath; + + public InternalTable table( + Table deltaKernelTable, Snapshot snapshot, Engine engine, String tableName, String basePath) { + try { + // Get schema from Delta Kernel's snapshot + io.delta.kernel.types.StructType schema = snapshot.getSchema(); + InternalSchema internalSchema = schemaExtractor.toInternalSchema(schema); + // Get partition columns); Review Comment: done ########## xtable-core/src/main/java/org/apache/xtable/kernel/DeltaKernelTableExtractor.java: ########## @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.xtable.kernel; + +import java.time.Instant; +import java.util.List; +import java.util.stream.Collectors; + +import lombok.Builder; + +import io.delta.kernel.*; +import io.delta.kernel.engine.Engine; +import io.delta.kernel.types.StructField; +import io.delta.kernel.types.StructType; + +import org.apache.xtable.model.InternalTable; +import org.apache.xtable.model.schema.InternalPartitionField; +import org.apache.xtable.model.schema.InternalSchema; +import org.apache.xtable.model.storage.DataLayoutStrategy; +import org.apache.xtable.model.storage.TableFormat; + +/** + * Extracts {@link InternalTable} canonical representation of a table at a point in time for Delta. + */ +@Builder +public class DeltaKernelTableExtractor { + @Builder.Default + private static final DeltaKernelSchemaExtractor schemaExtractor = + DeltaKernelSchemaExtractor.getInstance(); + + private final String basePath; + + public InternalTable table( + Table deltaKernelTable, Snapshot snapshot, Engine engine, String tableName, String basePath) { + try { + // Get schema from Delta Kernel's snapshot + io.delta.kernel.types.StructType schema = snapshot.getSchema(); + InternalSchema internalSchema = schemaExtractor.toInternalSchema(schema); + // Get partition columns); + StructType fullSchema = snapshot.getSchema(); // The full table schema + List<String> partitionColumns = snapshot.getPartitionColumnNames(); // List<String> Review Comment: done. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
