@@ -536,6 +536,24 @@ class StrictMetricsEvaluatorMigratedTest : public StrictMetricsEvaluatorTest {
536536 return data_file;
537537 }
538538
539+ std::shared_ptr<DataFile> MakeUnknownRecordCountFile () {
540+ auto data_file = std::make_shared<DataFile>();
541+ data_file->file_path = " unknown.parquet" ;
542+ data_file->file_format = FileFormatType::kParquet ;
543+ // -1 is the sentinel for an unknown row count.
544+ data_file->record_count = -1 ;
545+ return data_file;
546+ }
547+
548+ std::shared_ptr<DataFile> MakeInvalidRecordCountFile () {
549+ auto data_file = std::make_shared<DataFile>();
550+ data_file->file_path = " invalid.parquet" ;
551+ data_file->file_format = FileFormatType::kParquet ;
552+ // Anything below the -1 sentinel is invalid metadata.
553+ data_file->record_count = -2 ;
554+ return data_file;
555+ }
556+
539557 void ExpectShouldRead (const std::shared_ptr<Expression>& expr, bool expected,
540558 std::shared_ptr<DataFile> file = nullptr ,
541559 bool case_sensitive = true ) {
@@ -650,6 +668,23 @@ TEST_F(StrictMetricsEvaluatorMigratedTest, ZeroRecordFile) {
650668 }
651669}
652670
671+ TEST_F (StrictMetricsEvaluatorMigratedTest, UnknownRecordCountFile) {
672+ // A file with an unknown row count (record_count == -1) must not be treated as if
673+ // every row matches the predicate. AlwaysFalse can never match all rows.
674+ auto unknown_record_count_file = MakeUnknownRecordCountFile ();
675+ ExpectShouldRead (Expressions::AlwaysFalse (), false , unknown_record_count_file);
676+ }
677+
678+ TEST_F (StrictMetricsEvaluatorMigratedTest, InvalidRecordCountFile) {
679+ // A record count below the -1 unknown sentinel is invalid and must error out.
680+ auto invalid_record_count_file = MakeInvalidRecordCountFile ();
681+ ICEBERG_UNWRAP_OR_FAIL (auto evaluator, StrictMetricsEvaluator::Make (
682+ Expressions::AlwaysFalse (), schema_, true ));
683+ auto result = evaluator->Evaluate (*invalid_record_count_file);
684+ ASSERT_FALSE (result.has_value ());
685+ EXPECT_EQ (result.error ().kind , ErrorKind::kInvalidArgument );
686+ }
687+
653688TEST_F (StrictMetricsEvaluatorMigratedTest, Not) {
654689 ExpectShouldRead (
655690 Expressions::Not (Expressions::LessThan (" id" , Literal::Long (kIntMinValue - 25 ))),
0 commit comments