Acfboy commented on code in PR #20383:
URL: https://github.com/apache/datafusion/pull/20383#discussion_r2813128777
##########
datafusion/expr/src/expr_schema.rs:
##########
@@ -697,6 +716,13 @@ pub fn cast_subquery(subquery: Subquery, cast_to_type:
&DataType) -> Result<Subq
})
}
+/// Determine whether the given data type `dt` supports the negation operator.
+///
+/// Negation is supported for numeric, interval, timestamp types, and null.
+pub fn is_negatable(dt: &DataType) -> bool {
+ dt.is_numeric() || is_interval(dt) || is_timestamp(dt) || dt.is_null()
Review Comment:
This is to ensure consistency with the current codebase, as several tests
(e.g., test_simplify_negated_bitwise_and in the simplifier) already cover
negation on unsigned types. I'm still evaluating if this behavior is
intentional or an oversight. It appears there may be some issues with how
negation is handled in the optimizer; specifically, it seems the negation
operator might also be representing a bitwise NOT during the planning phase.
For example:
https://github.com/apache/datafusion/blob/b0566c57cc0b9ee2db8465f53fbd0d6e9e08798c/datafusion/optimizer/src/simplify_expressions/utils.rs#L254-L257
For now, I've kept the logic consistent with the previous behavior.
--
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]