Skip to content

Commit 93bf6ac

Browse files
authored
chore: fix IsBoundVisitor to error on AlwaysTrue & AlwaysFalse (#503)
1 parent 84814bc commit 93bf6ac

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/iceberg/expression/binder.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,13 @@ Result<bool> IsBoundVisitor::IsBound(const std::shared_ptr<Expression>& expr) {
8585
return Visit<bool, IsBoundVisitor>(expr, visitor);
8686
}
8787

88-
Result<bool> IsBoundVisitor::AlwaysTrue() { return true; }
88+
Result<bool> IsBoundVisitor::AlwaysTrue() {
89+
return InvalidExpression("IsBoundVisitor does not support AlwaysTrue expression");
90+
}
8991

90-
Result<bool> IsBoundVisitor::AlwaysFalse() { return true; }
92+
Result<bool> IsBoundVisitor::AlwaysFalse() {
93+
return InvalidExpression("IsBoundVisitor does not support AlwaysFalse expression");
94+
}
9195

9296
Result<bool> IsBoundVisitor::Not(bool child_result) { return child_result; }
9397

src/iceberg/test/expression_visitor_test.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,14 @@ TEST_F(BinderTest, ErrorNestedUnboundField) {
296296
class IsBoundVisitorTest : public ExpressionVisitorTest {};
297297

298298
TEST_F(IsBoundVisitorTest, Constants) {
299-
// True and False are always considered bound
299+
// True and False should error out
300300
auto true_expr = Expressions::AlwaysTrue();
301-
ICEBERG_UNWRAP_OR_FAIL(auto is_bound_true, IsBoundVisitor::IsBound(true_expr));
302-
EXPECT_TRUE(is_bound_true);
301+
auto result_true = IsBoundVisitor::IsBound(true_expr);
302+
EXPECT_THAT(result_true, IsError(ErrorKind::kInvalidExpression));
303303

304304
auto false_expr = Expressions::AlwaysFalse();
305-
ICEBERG_UNWRAP_OR_FAIL(auto is_bound_false, IsBoundVisitor::IsBound(false_expr));
306-
EXPECT_TRUE(is_bound_false);
305+
auto result_false = IsBoundVisitor::IsBound(false_expr);
306+
EXPECT_THAT(result_false, IsError(ErrorKind::kInvalidExpression));
307307
}
308308

309309
TEST_F(IsBoundVisitorTest, UnboundPredicate) {

0 commit comments

Comments
 (0)