in xtable-core/src/main/java/org/apache/xtable/iceberg/IcebergColumnStatsConverter.java [53:87]
public Metrics toIceberg(Schema schema, long totalRowCount, List<ColumnStat> fieldColumnStats) {
Map<Integer, Long> columnSizes = new HashMap<>();
Map<Integer, Long> valueCounts = new HashMap<>();
Map<Integer, Long> nullValueCounts = new HashMap<>();
Map<Integer, Long> nanValueCounts = null; // InternalTable currently doesn't track this
Map<Integer, ByteBuffer> lowerBounds = new HashMap<>();
Map<Integer, ByteBuffer> upperBounds = new HashMap<>();
fieldColumnStats.forEach(
columnStats -> {
InternalField field = columnStats.getField();
Types.NestedField icebergField =
schema.findField(IcebergSchemaExtractor.convertFromXTablePath(field.getPath()));
int fieldId = icebergField.fieldId();
columnSizes.put(fieldId, columnStats.getTotalSize());
valueCounts.put(fieldId, columnStats.getNumValues());
nullValueCounts.put(fieldId, columnStats.getNumNulls());
Type fieldType = icebergField.type();
if (columnStats.getRange().getMinValue() != null) {
lowerBounds.put(
fieldId, Conversions.toByteBuffer(fieldType, columnStats.getRange().getMinValue()));
}
if (columnStats.getRange().getMaxValue() != null) {
upperBounds.put(
fieldId, Conversions.toByteBuffer(fieldType, columnStats.getRange().getMaxValue()));
}
});
return new Metrics(
totalRowCount,
columnSizes,
valueCounts,
nullValueCounts,
nanValueCounts,
lowerBounds,
upperBounds);
}