Skip to content

Commit e7344ea

Browse files
committed
test(expr): add regression tests for missing null/NaN count entries
Cover the scenario where a field is absent from null_value_counts or nan_value_counts while the map is non-empty. Verify that comparison operators conservatively return kRowsMightNotMatch instead of incorrectly claiming kRowsMustMatch.
1 parent 4308fee commit e7344ea

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

‎src/iceberg/test/strict_metrics_evaluator_test.cc‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,4 +846,51 @@ TEST_F(StrictMetricsEvaluatorMigratedTest, EvaluateOnNestedColumnWithStats) {
846846
ExpectShouldRead(Expressions::NotNull("struct.nested_col_with_stats"), false);
847847
}
848848

849+
TEST_F(StrictMetricsEvaluatorMigratedTest, MissingNullCountForField) {
850+
// Field 14 (no_nan_stats, float64, optional) has bounds and value_counts but is
851+
// missing from null_value_counts. The evaluator must conservatively assume nulls
852+
// may exist and return kRowsMightNotMatch for comparison operators.
853+
auto data_file = std::make_shared<DataFile>();
854+
data_file->file_path = "null_test.parquet";
855+
data_file->file_format = FileFormatType::kParquet;
856+
data_file->record_count = 50;
857+
data_file->value_counts = {{14, 50L}};
858+
data_file->null_value_counts = {{4, 0L}, {5, 0L}};
859+
data_file->nan_value_counts = {{14, 0L}};
860+
data_file->lower_bounds = {{14, Literal::Double(1.0).Serialize().value()}};
861+
data_file->upper_bounds = {{14, Literal::Double(100.0).Serialize().value()}};
862+
863+
ExpectShouldRead(Expressions::LessThan("no_nan_stats", Literal::Double(200.0)), false,
864+
data_file);
865+
ExpectShouldRead(Expressions::LessThanOrEqual("no_nan_stats", Literal::Double(200.0)),
866+
false, data_file);
867+
ExpectShouldRead(Expressions::GreaterThan("no_nan_stats", Literal::Double(-1.0)), false,
868+
data_file);
869+
ExpectShouldRead(
870+
Expressions::GreaterThanOrEqual("no_nan_stats", Literal::Double(-1.0)), false,
871+
data_file);
872+
ExpectShouldRead(Expressions::Equal("no_nan_stats", Literal::Double(50.0)), false,
873+
data_file);
874+
}
875+
876+
TEST_F(StrictMetricsEvaluatorMigratedTest, MissingNanCountForField) {
877+
// Field 14 (no_nan_stats, float64, optional) is missing from nan_value_counts.
878+
// For a floating-point field, the evaluator must conservatively assume NaNs may
879+
// exist and return kRowsMightNotMatch for comparison operators.
880+
auto data_file = std::make_shared<DataFile>();
881+
data_file->file_path = "nan_test.parquet";
882+
data_file->file_format = FileFormatType::kParquet;
883+
data_file->record_count = 50;
884+
data_file->value_counts = {{14, 50L}};
885+
data_file->null_value_counts = {{14, 0L}};
886+
data_file->nan_value_counts = {{8, 0L}};
887+
data_file->lower_bounds = {{14, Literal::Double(1.0).Serialize().value()}};
888+
data_file->upper_bounds = {{14, Literal::Double(100.0).Serialize().value()}};
889+
890+
ExpectShouldRead(Expressions::LessThan("no_nan_stats", Literal::Double(200.0)), false,
891+
data_file);
892+
ExpectShouldRead(Expressions::GreaterThan("no_nan_stats", Literal::Double(-1.0)), false,
893+
data_file);
894+
}
895+
849896
} // namespace iceberg

0 commit comments

Comments
 (0)