File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1527,12 +1527,14 @@ def eval(self, file: DataFile) -> bool:
15271527 Returns: false if the file may contain any row that doesn't match
15281528 the expression, true otherwise.
15291529 """
1530- if file .record_count <= 0 :
1531- # Older version don't correctly implement record count from avro file and thus
1532- # set record count -1 when importing avro tables to iceberg tables. This should
1533- # be updated once we implemented and set correct record count.
1530+ if file .record_count == 0 :
15341531 return ROWS_MUST_MATCH
15351532
1533+ if file .record_count < 0 :
1534+ # Older versions set the record count to -1 when importing Avro tables.
1535+ # Treat an unknown count conservatively rather than as an empty file.
1536+ return ROWS_MIGHT_NOT_MATCH
1537+
15361538 return visit (self .expr , _StrictMetricsEvaluationVisitor (self .struct , file ))
15371539
15381540
Original file line number Diff line number Diff line change @@ -1523,7 +1523,7 @@ def test_metrics_evaluator_record_count_short_circuits() -> None:
15231523 )
15241524 assert _InclusiveMetricsEvaluator (schema , EqualTo ("x" , 10 )).eval (negative_record_file ) is ROWS_MIGHT_MATCH
15251525 assert _StrictMetricsEvaluator (schema , EqualTo ("x" , 10 )).eval (zero_record_file ) is ROWS_MUST_MATCH
1526- assert _StrictMetricsEvaluator (schema , EqualTo ("x" , 10 )).eval (negative_record_file ) is ROWS_MUST_MATCH
1526+ assert _StrictMetricsEvaluator (schema , EqualTo ("x" , 10 )).eval (negative_record_file ) is ROWS_MIGHT_NOT_MATCH
15271527
15281528
15291529def test_strict_not (schema_data_file : Schema , strict_data_file_1 : DataFile ) -> None :
You can’t perform that action at this time.
0 commit comments