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


##########
xtable-core/src/main/java/org/apache/xtable/parquet/ParquetPartitionValueExtractor.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.parquet;
+
+import java.util.*;
+
+import lombok.NonNull;
+
+import org.apache.parquet.hadoop.metadata.ParquetMetadata;
+import org.apache.parquet.schema.MessageType;
+
+import org.apache.xtable.hudi.PathBasedPartitionValuesExtractor;
+import org.apache.xtable.model.schema.InternalPartitionField;
+import org.apache.xtable.model.schema.InternalSchema;
+import org.apache.xtable.model.stat.PartitionValue;
+import org.apache.xtable.model.stat.Range;
+
+/** Partition value extractor for Parquet. */
+public class ParquetPartitionValueExtractor extends 
PathBasedPartitionValuesExtractor {
+  private static final ParquetPartitionValueExtractor INSTANCE =
+      new ParquetPartitionValueExtractor(Collections.emptyMap());
+  private static final ParquetSchemaExtractor schemaExtractor =
+      ParquetSchemaExtractor.getInstance();
+  private static final ParquetMetadataExtractor parquetMetadataExtractor =
+      ParquetMetadataExtractor.getInstance();
+  private static final ParquetPartitionSpecExtractor partitionSpecExtractor =
+      ParquetPartitionSpecExtractor.getInstance();
+
+  public ParquetPartitionValueExtractor(@NonNull Map<String, String> 
pathToPartitionFieldFormat) {
+    super(pathToPartitionFieldFormat);
+  }
+
+  public List<PartitionValue> extractPartitionValues(
+      List<InternalPartitionField> partitionColumns, String partitionPath) {
+    if (partitionColumns.size() == 0) {
+      return Collections.emptyList();
+    }
+    int totalNumberOfPartitions = 
partitionColumns.get(0).getPartitionFieldNames().size();
+    List<PartitionValue> result = new ArrayList<>(totalNumberOfPartitions);
+    String remainingPartitionPath = partitionPath;
+    for (InternalPartitionField partitionField : partitionColumns) {
+      int index = 0;
+      for (String partitionFieldName : 
partitionField.getPartitionFieldNames()) {
+        if (remainingPartitionPath.startsWith(partitionFieldName + "=")) {
+          remainingPartitionPath =
+              remainingPartitionPath.substring(partitionFieldName.length() + 
1);
+        }
+        PartialResult valueAndRemainingPath =
+            parsePartitionPath(
+                partitionField, remainingPartitionPath, 
totalNumberOfPartitions, index);
+        result.add(
+            PartitionValue.builder()
+                .partitionField(partitionField)
+                .range(Range.scalar(valueAndRemainingPath.getValue()))
+                .build());
+        index++;
+        remainingPartitionPath = valueAndRemainingPath.getRemainingPath();
+      }
+    }
+    return result;
+  }
+
+  protected PartialResult parsePartitionPath(
+      InternalPartitionField field, String remainingPath, int 
totalNumberOfPartitions, int index) {
+    switch (field.getTransformType()) {
+      case YEAR:
+      case MONTH: // TODO split and get the value of month from 
pathToPartitionFieldFormat

Review Comment:
   that was the old partitioning logic, it is the same for all cases (as Hudi's 
case), just removed the comments here.



##########
xtable-core/src/main/java/org/apache/xtable/parquet/ParquetSchemaExtractor.java:
##########
@@ -97,6 +98,11 @@ public InternalSchema toInternalSchema(Type schema, String 
parentPath) {
       primitiveType = schema.asPrimitiveType();
       switch (primitiveType.getPrimitiveTypeName()) {
           // PrimitiveTypes
+        case INT96: // TODO check logicaltypes of INT96
+          metadata.put(
+              InternalSchema.MetadataKey.TIMESTAMP_PRECISION, 
InternalSchema.MetadataValue.MILLIS);

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]

Reply via email to