the-other-tim-brown commented on code in PR #1012:
URL: https://github.com/apache/incubator-xtable/pull/1012#discussion_r4636842318
##########
xtable-core/src/main/java/org/apache/xtable/iceberg/IcebergColumnStatsConverter.java:
##########
@@ -93,20 +93,26 @@ public List<ColumnStat> fromIceberg(
Map<Integer, Long> size,
Map<Integer, ByteBuffer> minValues,
Map<Integer, ByteBuffer> maxValues) {
- if (valueCounts == null || valueCounts.isEmpty()) {
+ // Iceberg writers may omit any of these metrics. A field without a null
count is skipped, like
+ // one without a value count, since a null count of zero would let targets
skip the file for
+ // IS NULL filters. A missing column size is reported as zero.
+ if (valueCounts == null || valueCounts.isEmpty() || nullCounts == null) {
return Collections.emptyList();
}
return fields.stream()
- .filter(field -> valueCounts.containsKey(field.getFieldId()))
+ .filter(
+ field ->
+ valueCounts.containsKey(field.getFieldId())
+ && nullCounts.containsKey(field.getFieldId()))
Review Comment:
Should we also check that the value is non-null or does the spec guarantee
that we will have a non-null value?
##########
xtable-core/src/main/java/org/apache/xtable/iceberg/IcebergColumnStatsConverter.java:
##########
@@ -93,20 +93,26 @@ public List<ColumnStat> fromIceberg(
Map<Integer, Long> size,
Map<Integer, ByteBuffer> minValues,
Map<Integer, ByteBuffer> maxValues) {
- if (valueCounts == null || valueCounts.isEmpty()) {
+ // Iceberg writers may omit any of these metrics. A field without a null
count is skipped, like
+ // one without a value count, since a null count of zero would let targets
skip the file for
+ // IS NULL filters. A missing column size is reported as zero.
+ if (valueCounts == null || valueCounts.isEmpty() || nullCounts == null) {
Review Comment:
If `nullCounts` is not set but the min/max are, wouldn't we want to emit
them?
##########
xtable-core/src/main/java/org/apache/xtable/iceberg/IcebergColumnStatsConverter.java:
##########
@@ -93,20 +93,26 @@ public List<ColumnStat> fromIceberg(
Map<Integer, Long> size,
Map<Integer, ByteBuffer> minValues,
Map<Integer, ByteBuffer> maxValues) {
- if (valueCounts == null || valueCounts.isEmpty()) {
+ // Iceberg writers may omit any of these metrics. A field without a null
count is skipped, like
+ // one without a value count, since a null count of zero would let targets
skip the file for
+ // IS NULL filters. A missing column size is reported as zero.
+ if (valueCounts == null || valueCounts.isEmpty() || nullCounts == null) {
return Collections.emptyList();
}
return fields.stream()
- .filter(field -> valueCounts.containsKey(field.getFieldId()))
+ .filter(
+ field ->
+ valueCounts.containsKey(field.getFieldId())
+ && nullCounts.containsKey(field.getFieldId()))
.map(
field -> {
Integer fieldId = field.getFieldId();
long numValues = valueCounts.get(fieldId);
long numNulls = nullCounts.get(fieldId);
- long totalSize = size.get(fieldId);
+ long totalSize = size == null ? 0L : size.getOrDefault(fieldId,
0L);
Review Comment:
Should we update the `ColumnStat` to take a `Long` for the `totalSize` so we
can distinguish between when it is zero and when it is not set?
--
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]