wgtmac commented on code in PR #686:
URL: https://github.com/apache/iceberg-cpp/pull/686#discussion_r3315949845
##########
src/iceberg/expression/strict_metrics_evaluator.cc:
##########
@@ -436,18 +436,39 @@ class StrictMetricsVisitor : public BoundVisitor<bool> {
}
bool CanContainNulls(int32_t id) {
+ auto field_result = schema_.GetFieldById(id);
+ if (field_result.has_value() && field_result->has_value() &&
Review Comment:
We should preserve error returned by `schema_.GetFieldById`, so we need to
change the return type to `Result<bool>`. BTW, why calling `GetFieldById`
instead of `FindFieldById`? They are semantically different.
##########
src/iceberg/expression/strict_metrics_evaluator.cc:
##########
@@ -436,18 +436,39 @@ class StrictMetricsVisitor : public BoundVisitor<bool> {
}
bool CanContainNulls(int32_t id) {
+ auto field_result = schema_.GetFieldById(id);
+ if (field_result.has_value() && field_result->has_value() &&
+ !field_result->value().get().optional()) {
+ return false;
+ }
+
if (data_file_.null_value_counts.empty()) {
return true;
}
auto it = data_file_.null_value_counts.find(id);
- return it != data_file_.null_value_counts.cend() && it->second > 0;
+ if (it == data_file_.null_value_counts.cend()) {
+ return true;
+ }
+ return it->second > 0;
}
bool CanContainNaNs(int32_t id) {
- // nan counts might be null for early version writers when nan counters
are not
Review Comment:
I think the original implementation matches the Java parity exactly, which
assumes null_value_counts should populate all fields but nan_value_counts don't
(when they are not empty). I agree current PR is a nice fix. I still suggest
keeping this comment since it still holds.
##########
src/iceberg/test/strict_metrics_evaluator_test.cc:
##########
@@ -846,4 +846,50 @@ TEST_F(StrictMetricsEvaluatorMigratedTest,
EvaluateOnNestedColumnWithStats) {
ExpectShouldRead(Expressions::NotNull("struct.nested_col_with_stats"),
false);
}
+TEST_F(StrictMetricsEvaluatorMigratedTest, MissingNullCountForField) {
Review Comment:
This is not migrated from Java implementation so please do not use this
confusing name.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]