rdblue commented on a change in pull request #1963:
URL: https://github.com/apache/iceberg/pull/1963#discussion_r569624421
##########
File path: core/src/main/java/org/apache/iceberg/avro/ValueWriters.java
##########
@@ -369,17 +393,42 @@ private OptionWriter(int nullIndex, ValueWriter<T>
valueWriter) {
throw new IllegalArgumentException("Invalid option index: " +
nullIndex);
}
this.valueWriter = valueWriter;
+ this.type = type;
+ this.nullValueCount = 0;
}
@Override
public void write(T option, Encoder encoder) throws IOException {
if (option == null) {
encoder.writeIndex(nullIndex);
+ nullValueCount++;
} else {
encoder.writeIndex(valueIndex);
valueWriter.write(option, encoder);
}
}
+
+ @Override
+ public Stream<FieldMetrics> metrics() {
+ if (AvroSchemaUtil.isMetricSupportedType(type)) {
+ return mergeNullCountIntoMetric();
+ } else {
+ return valueWriter.metrics();
+ }
+ }
+
+ private Stream<FieldMetrics> mergeNullCountIntoMetric() {
+ List<FieldMetrics> fieldMetricsFromWriter =
valueWriter.metrics().collect(Collectors.toList());
+ Preconditions.checkState(fieldMetricsFromWriter.size() == 1,
+ "Optional field for type % shouldn't vend more than one field
metrics", type);
Review comment:
Typo: should be `%s` instead of `%`.
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]