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