-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Implement the bitwise_not in NotExpr #5902
Conversation
@@ -622,6 +622,17 @@ async fn test_not_expressions() -> Result<()> { | |||
]; | |||
assert_batches_eq!(expected, &actual); | |||
|
|||
let sql = "SELECT not(1), not(0)"; | |||
let actual = execute_to_batches(&ctx, sql).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe lets move it to scalar.slt
sqllogic test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it would be nice to move to https://github.com/apache/arrow-datafusion/blob/main/datafusion/core/tests/sqllogictests/test_files/scalar.slt but we can do that potentially as a follow on PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will port some tests over
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow on PR to port the tests: #5968
Ok(DataType::Boolean) | ||
fn data_type(&self, input_schema: &Schema) -> Result<DataType> { | ||
// Ok(DataType::Boolean) | ||
let data_type = self.arg.data_type(input_schema)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks breaking imho... I would propose to have the own BitwiseNotExpr
instead of making NotExpr
universal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @alamb suggestion, I embed bitwise_not into NotExpr. But I agree that this way will break NotExpr
original struct. I think I should further discuss the implementation in the issue #5700
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, sounds good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -622,6 +622,17 @@ async fn test_not_expressions() -> Result<()> { | |||
]; | |||
assert_batches_eq!(expected, &actual); | |||
|
|||
let sql = "SELECT not(1), not(0)"; | |||
let actual = execute_to_batches(&ctx, sql).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it would be nice to move to https://github.com/apache/arrow-datafusion/blob/main/datafusion/core/tests/sqllogictests/test_files/scalar.slt but we can do that potentially as a follow on PR
* feat: make NotExpr support integer Bitwise_not * feat: make NotExpr support integer Bitwise_not --------- Co-authored-by: RT_Enzyme <52275903001@stu.ecnu.edu.cn>
This reverts commit 87e5adc
…ache#6599) This reverts commit 87e5adc
Which issue does this PR close?
Closes #5700. Because the SQL dialect use
Generic
, sqlparser can't parse operator~
as unary Bitwise_not. But we can usenot
to complement integer instead of operator~
in SQL.Rationale for this change
What changes are included in this PR?
Extending Expr::Not to work with integral types so that it can evaluate Bitwise_not expression.
Are these changes tested?
Pass Integrated tests.
Add United tests for bitwise_not integral types.
Are there any user-facing changes?
Yes. The
not
can NOT boolean type and Bitwise_not integer in sql.