Skip to content

Commit 203b651

Browse files
committed
paimon: annotating assumptions with comments
1 parent 8400413 commit 203b651

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

xtable-core/src/main/java/org/apache/xtable/paimon/PaimonDataFileExtractor.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,22 @@ private List<ColumnStat> toColumnStats(DataFileMeta file, InternalSchema interna
9999
internalSchema.getAllFields().stream()
100100
.collect(Collectors.toMap(InternalField::getPath, f -> f));
101101

102-
// all columns are present in valueStats
102+
// stats for all columns are present in valueStats, we can safely ignore file.keyStats() - TODO: validate this assumption
103103
SimpleStats valueStats = file.valueStats();
104104
if (valueStats != null) {
105105
// log.info("Processing valueStats: {}", valueStats.toRow());
106106
List<String> colNames = file.valueStatsCols();
107107
// log.info("valueStatsCols: {}", colNames);
108108
if (colNames == null || colNames.isEmpty()) {
109+
// 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
109110
colNames =
110111
internalSchema.getAllFields().stream()
111112
.map(InternalField::getPath)
112113
.collect(Collectors.toList());
113114
}
114115

115116
if (colNames.size() != valueStats.minValues().getFieldCount()) {
117+
// paranoia check - this should never happen, but if the code reaches here, then there is a bug! Please file a bug report
116118
throw new ReadException(
117119
String.format(
118120
"Mismatch between column stats names and values arity: names=%d, values=%d",
@@ -208,12 +210,12 @@ private Object getValue(BinaryRow row, int index, InternalType type, InternalSch
208210
fieldSchema.getName());
209211
tsPrecision = TimestampType.DEFAULT_PRECISION;
210212
}
213+
// TODO: BinaryRow.getTimestamp().toInstant() is deprecated (use LocalZoneTimestamp), but BinaryRow does not have a method to get LocalZoneTimestamp?
211214
Instant timestamp = row.getTimestamp(index, tsPrecision).toInstant();
212215
long tsMillis = timestamp.toEpochMilli();
213216

214217
// according to docs for org.apache.xtable.model.stat.Range, timestamp is stored as millis
215-
// or micros
216-
// even if precision is higher than micros, return micros
218+
// or micros - even if precision is higher than micros, return micros
217219
if (tsPrecisionEnum == InternalSchema.MetadataValue.MILLIS) {
218220
return tsMillis;
219221
} else {

0 commit comments

Comments
 (0)