findepi commented on code in PR #17088:
URL: https://github.com/apache/datafusion/pull/17088#discussion_r2266123523
##########
datafusion/expr-common/src/operator.rs:
##########
@@ -328,6 +328,55 @@ impl Operator {
Operator::Multiply | Operator::Divide | Operator::Modulo => 45,
}
}
+
+ /// Returns true if the `Expr::BinaryOperator` with this operator
+ /// is guaranteed to return null if either side is null.
+ pub fn returns_null_on_null(&self) -> bool {
+ match self {
+ Operator::Eq
+ | Operator::NotEq
+ | Operator::Lt
+ | Operator::LtEq
+ | Operator::Gt
+ | Operator::GtEq
+ | Operator::Plus
+ | Operator::Minus
+ | Operator::Multiply
+ | Operator::Divide
+ | Operator::Modulo
+ | Operator::RegexMatch
+ | Operator::RegexIMatch
+ | Operator::RegexNotMatch
+ | Operator::RegexNotIMatch
+ | Operator::LikeMatch
+ | Operator::ILikeMatch
+ | Operator::NotLikeMatch
+ | Operator::NotILikeMatch
+ | Operator::BitwiseAnd
+ | Operator::BitwiseOr
+ | Operator::BitwiseXor
+ | Operator::BitwiseShiftRight
+ | Operator::BitwiseShiftLeft
+ | Operator::AtArrow
+ | Operator::ArrowAt
+ | Operator::Arrow
+ | Operator::LongArrow
+ | Operator::HashArrow
+ | Operator::HashLongArrow
+ | Operator::AtAt
+ | Operator::IntegerDivide
+ | Operator::HashMinus
+ | Operator::AtQuestion
+ | Operator::Question
+ | Operator::QuestionAnd
+ | Operator::QuestionPipe => true,
+ Operator::Or
+ | Operator::And
+ | Operator::IsDistinctFrom
+ | Operator::IsNotDistinctFrom
+ | Operator::StringConcat => false,
Review Comment:
This function describes semantics of `Expr::BinaryExpr` when used with given
operator. This is a DataFusion logical expression which has a precisely
defined semantics. There is no more a concept of a dialect that's applicable
here. If this is confusing, I should avoid adding this method here, and keep it
in the optimizer code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]