|
22 | 22 | #include "iceberg/expression/binder.h" |
23 | 23 | #include "iceberg/expression/expressions.h" |
24 | 24 | #include "iceberg/expression/rewrite_not.h" |
| 25 | +#include "iceberg/result.h" |
25 | 26 | #include "iceberg/schema.h" |
26 | 27 | #include "iceberg/test/matchers.h" |
27 | 28 | #include "iceberg/type.h" |
@@ -521,11 +522,11 @@ TEST_F(ReferenceVisitorTest, Constants) { |
521 | 522 | } |
522 | 523 |
|
523 | 524 | TEST_F(ReferenceVisitorTest, UnboundPredicate) { |
524 | | - // Unbound predicates should have no referenced field IDs (not yet bound to schema) |
525 | 525 | auto unbound_pred = Expressions::Equal("name", Literal::String("Alice")); |
526 | | - ICEBERG_UNWRAP_OR_FAIL(auto refs, |
527 | | - ReferenceVisitor::GetReferencedFieldIds(unbound_pred)); |
528 | | - EXPECT_TRUE(refs.empty()); |
| 526 | + auto result = ReferenceVisitor::GetReferencedFieldIds(unbound_pred); |
| 527 | + EXPECT_THAT(result, IsError(ErrorKind::kInvalidExpression)); |
| 528 | + EXPECT_THAT(result, |
| 529 | + HasErrorMessage("Cannot get referenced field IDs from unbound predicate")); |
529 | 530 | } |
530 | 531 |
|
531 | 532 | TEST_F(ReferenceVisitorTest, BoundPredicate) { |
@@ -672,18 +673,15 @@ TEST_F(ReferenceVisitorTest, SetPredicates) { |
672 | 673 | } |
673 | 674 |
|
674 | 675 | TEST_F(ReferenceVisitorTest, MixedBoundAndUnbound) { |
675 | | - // Expression with both bound and unbound predicates |
676 | 676 | auto bound_pred = Expressions::Equal("name", Literal::String("Alice")); |
677 | 677 | ICEBERG_UNWRAP_OR_FAIL(auto pred1, Bind(bound_pred)); |
678 | | - |
679 | 678 | auto unbound_pred = Expressions::GreaterThan("age", Literal::Int(25)); |
680 | | - |
681 | 679 | auto mixed_and = Expressions::And(pred1, unbound_pred); |
682 | | - ICEBERG_UNWRAP_OR_FAIL(auto refs, ReferenceVisitor::GetReferencedFieldIds(mixed_and)); |
683 | 680 |
|
684 | | - // Should only return field IDs from bound predicates |
685 | | - EXPECT_EQ(refs.size(), 1); |
686 | | - EXPECT_EQ(refs.count(2), 1); // name field only |
| 681 | + auto result = ReferenceVisitor::GetReferencedFieldIds(mixed_and); |
| 682 | + EXPECT_THAT(result, IsError(ErrorKind::kInvalidExpression)); |
| 683 | + EXPECT_THAT(result, |
| 684 | + HasErrorMessage("Cannot get referenced field IDs from unbound predicate")); |
687 | 685 | } |
688 | 686 |
|
689 | 687 | TEST_F(ReferenceVisitorTest, AllFields) { |
|
0 commit comments