edgarRd commented on a change in pull request #227: ORC column map fix
URL: https://github.com/apache/incubator-iceberg/pull/227#discussion_r299214348
##########
File path: orc/src/main/java/org/apache/iceberg/orc/OrcFileAppender.java
##########
@@ -95,24 +97,16 @@ public Metrics metrics() {
// we don't currently have columnSizes or distinct counts.
Map<Integer, Long> valueCounts = new HashMap<>();
Map<Integer, Long> nullCounts = new HashMap<>();
- Integer[] icebergIds = new Integer[orcSchema.getMaximumId() + 1];
- for (TypeDescription type : columnIds.keySet()) {
- icebergIds[type.getId()] = columnIds.get(type);
- }
- for (int c = 1; c < stats.length; ++c) {
- if (icebergIds[c] != null) {
- valueCounts.put(icebergIds[c], stats[c].getNumberOfValues());
- }
- }
- for (TypeDescription child : orcSchema.getChildren()) {
- int childId = child.getId();
- if (icebergIds[childId] != null) {
- nullCounts.put(icebergIds[childId], rows -
stats[childId].getNumberOfValues());
- }
+ Map<ColumnMap.IcebergColumn, TypeDescription> icebertToOrc =
columnIds.inverse();
+ for (Types.NestedField field : schema.columns()) {
+ TypeDescription orcCol = icebertToOrc.get(
+ ColumnMap.newIcebergColumn(field.fieldId(), field.isRequired()));
+ valueCounts.put(field.fieldId(),
stats[orcCol.getId()].getNumberOfValues());
+ nullCounts.put(field.fieldId(), rows -
stats[orcCol.getId()].getNumberOfValues());
Review comment:
This is a good point. This is the original code but I think you're right.
This does not count for repeated values either so the null count is actually
incorrect as per
https://github.com/apache/orc/blob/master/java/core/src/java/org/apache/orc/ColumnStatistics.java#L29
- This would mean that even if the file didn't have any `null` value, repeated
values would look like null ones because of this operation.
Since ORC only records whether a column `hasNull` values, I wonder if
there's an alternative to this otherwise we probably need to not support this
for now. Any ideas @omalley ?
Btw, this code in `OrcFileAppender` will be replaced by the ORC Metrics
computed in https://github.com/apache/incubator-iceberg/pull/199
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]