unical1988 commented on code in PR #650:
URL: https://github.com/apache/incubator-xtable/pull/650#discussion_r1967308115


##########
xtable-core/src/main/java/org/apache/xtable/parquet/ParquetTableExtractor.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.delta;
+
+import java.time.Instant;
+import java.util.List;
+
+import lombok.Builder;
+
+import org.apache.parquet.hadoop.ParquetFileReader;
+
+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 ParquetTableExtractor {
+  @Builder.Default
+  private static final ParquetSchemaExtractor schemaExtractor = 
ParquetTableExtractor.getInstance();
+  @Builder.Default
+  private static final ParquetPartitionExtractor partitionExtractor = 
ParquetPartitionExtractor.getInstance();
+  @Builder.Default
+  private static final ParquetMetadataExtractor parquetMetadataExtractor =
+          ParquetMetadataExtractor.getInstance();
+  private Map<String, List<String>> initPartitionInfo() {
+    return getPartitionFromDirectoryStructure(hadoopConf, basePath, 
Collections.emptyMap());
+  }
+
+  public InternalTable table(String tableName, Long version) {
+    ParquetMetadata footer =
+            parquetMetadataExtractor.readParquetMetadata(conf, path);
+    MessageType schema = parquetMetadataExtractor.getSchema(footer);
+    InternalSchema schema = schemaExtractor.toInternalSchema(schema);
+    Set<String> partitionKeys = initPartitionInfo().keySet();
+    List<InternalPartitionField> partitionFields =
+            partitionExtractor
+            .getInternalPartitionField(partitionKeys,schema);

Review Comment:
   does this mean that 
   
   1. `getPartitionFromDirectoryStructure() ` (in 
`ParquetConversionSource.java`) should return the partition accounting for the 
table name (only one file)?
   2. that same method should maybe consider returning partition values for the 
table and not field names (e.g., in line 254 
```currentPartitionMap.computeIfAbsent(partitionKeyValue[1]/*instead of the 
actual partitionKeyValue[0]*/, k ->new 
ArrayList<>()).add(partitionKeyValue[1]);```)?
   
   



-- 
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: commits-unsubscr...@xtable.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to