Skip to content

Commit f1b0dba

Browse files
authored
fix: UnboundPredicateImpl::Make failed to check op type (apache#348)
1 parent 4a71abe commit f1b0dba

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/iceberg/expression/expressions.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <string>
2828
#include <vector>
2929

30-
#include "iceberg/exception.h"
3130
#include "iceberg/expression/literal.h"
3231
#include "iceberg/expression/predicate.h"
3332
#include "iceberg/expression/term.h"

src/iceberg/expression/predicate.cc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "iceberg/expression/predicate.h"
2121

2222
#include <algorithm>
23-
#include <cmath>
2423
#include <format>
2524

2625
#include "iceberg/expression/expressions.h"
@@ -50,7 +49,9 @@ Result<std::unique_ptr<UnboundPredicateImpl<B>>> UnboundPredicateImpl<B>::Make(
5049
if (!term) [[unlikely]] {
5150
return InvalidExpression("UnboundPredicate cannot have null term");
5251
}
53-
if (op == Expression::Operation::kIn || op == Expression::Operation::kNotIn) {
52+
if (op != Expression::Operation::kIsNull && op != Expression::Operation::kNotNull &&
53+
op != Expression::Operation::kIsNan && op != Expression::Operation::kNotNan)
54+
[[unlikely]] {
5455
return InvalidExpression("Cannot create {} predicate without a value",
5556
::iceberg::ToString(op));
5657
}
@@ -64,6 +65,16 @@ Result<std::unique_ptr<UnboundPredicateImpl<B>>> UnboundPredicateImpl<B>::Make(
6465
if (!term) [[unlikely]] {
6566
return InvalidExpression("UnboundPredicate cannot have null term");
6667
}
68+
if (op == Expression::Operation::kIsNull || op == Expression::Operation::kNotNull ||
69+
op == Expression::Operation::kIsNan || op == Expression::Operation::kNotNan)
70+
[[unlikely]] {
71+
return InvalidExpression("Cannot create {} predicate inclusive a value",
72+
::iceberg::ToString(op));
73+
}
74+
if (value.IsNaN()) [[unlikely]] {
75+
return InvalidExpression(
76+
"Invalid expression literal: NaN, use isNaN or notNaN instead");
77+
}
6778
return std::unique_ptr<UnboundPredicateImpl<B>>(
6879
new UnboundPredicateImpl<B>(op, std::move(term), std::move(value)));
6980
}

0 commit comments

Comments
 (0)