mao-liu commented on code in PR #767:
URL: https://github.com/apache/incubator-xtable/pull/767#discussion_r2674605975
##########
xtable-core/src/main/java/org/apache/xtable/paimon/PaimonDataFileExtractor.java:
##########
@@ -78,10 +93,154 @@ private String toFullPhysicalPath(FileStoreTable table,
ManifestEntry entry) {
}
}
- private List<ColumnStat> toColumnStats(DataFileMeta file) {
- // TODO: Implement logic to extract column stats from the file meta
- // https://github.com/apache/incubator-xtable/issues/755
- return Collections.emptyList();
+ private List<ColumnStat> toColumnStats(DataFileMeta file, InternalSchema
internalSchema) {
+ List<ColumnStat> columnStats = new ArrayList<>();
+ Map<String, InternalField> fieldMap =
+ internalSchema.getAllFields().stream()
+ .collect(Collectors.toMap(InternalField::getPath, f -> f));
+
+ // stats for all columns are present in valueStats, we can safely ignore
file.keyStats() - TODO: validate this assumption
+ SimpleStats valueStats = file.valueStats();
+ if (valueStats != null) {
+ // log.info("Processing valueStats: {}", valueStats.toRow());
+ List<String> colNames = file.valueStatsCols();
+ // log.info("valueStatsCols: {}", colNames);
+ if (colNames == null || colNames.isEmpty()) {
+ // if column names are not present, we assume all columns in the
schema are present in the same order as the schema - TODO: validate this
assumption
Review Comment:
Validated: https://lists.apache.org/thread/ph4xjpvy5qzdbp8h31d2q63kjybchzov
##########
xtable-core/src/main/java/org/apache/xtable/paimon/PaimonStatsExtractor.java:
##########
@@ -0,0 +1,189 @@
+/*
+ * 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.paimon;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import lombok.extern.log4j.Log4j2;
+
+import org.apache.paimon.data.BinaryArray;
+import org.apache.paimon.data.BinaryRow;
+import org.apache.paimon.data.Timestamp;
+import org.apache.paimon.io.DataFileMeta;
+import org.apache.paimon.stats.SimpleStats;
+import org.apache.paimon.types.TimestampType;
+
+import org.apache.xtable.exception.ReadException;
+import org.apache.xtable.model.schema.InternalField;
+import org.apache.xtable.model.schema.InternalSchema;
+import org.apache.xtable.model.schema.InternalType;
+import org.apache.xtable.model.stat.ColumnStat;
+import org.apache.xtable.model.stat.Range;
+
+@Log4j2
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public class PaimonStatsExtractor {
+ private static final PaimonStatsExtractor INSTANCE = new
PaimonStatsExtractor();
+
+ public static PaimonStatsExtractor getInstance() {
+ return INSTANCE;
+ }
+
+ public List<ColumnStat> extractColumnStats(DataFileMeta file, InternalSchema
internalSchema) {
+ List<ColumnStat> columnStats = new ArrayList<>();
+ Map<String, InternalField> fieldMap =
+ internalSchema.getAllFields().stream()
+ .collect(Collectors.toMap(InternalField::getPath, f -> f));
+
+ // stats for all columns are present in valueStats, we can safely ignore
file.keyStats() - TODO:
Review Comment:
Validated: https://lists.apache.org/thread/ph4xjpvy5qzdbp8h31d2q63kjybchzov
--
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]