Skip to content
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

Implement the bitwise complement operator #5700

Closed
RTEnzyme opened this issue Mar 23, 2023 · 2 comments · Fixed by #5902
Closed

Implement the bitwise complement operator #5700

RTEnzyme opened this issue Mar 23, 2023 · 2 comments · Fixed by #5902
Labels
enhancement New feature or request

Comments

@RTEnzyme
Copy link
Contributor

Is your feature request related to a problem or challenge?

The issue #1619 have discussed the bitwise operations. And some of the operations have been implemented: &, #, |, << and >>.

But the unary bitwise Complement operator ~ hasn't been implemented. I believe that the addition of the bitwise ~ operator would be a valuable addition to the existing set of bitwise operators.

Describe the solution you'd like

I would appreciate any suggestions on how to approach this task.

Describe alternatives you've considered

No response

Additional context

No response

@alamb
Copy link
Contributor

alamb commented Mar 23, 2023

In order to implement this feature I would suggest extending Expr::Not to work with integral types

https://github.com/apache/arrow-datafusion/blob/8594ec73184b348ba23cf23458f1fc5340505d13/datafusion/expr/src/expr.rs#L104C51-L105

There is already an arrow kernel that can be used: https://docs.rs/arrow/35.0.0/arrow/compute/kernels/bitwise/fn.bitwise_not.html

You may also have to figure out how to get the ~col to work -- sqlparser supports it -- https://docs.rs/sqlparser/0.32.0/sqlparser/ast/enum.UnaryOperator.html#variant.PGBitwiseNot

@RTEnzyme
Copy link
Contributor Author

In order to implement this feature I would suggest extending Expr::Not to work with integral types

Thanks for your suggestion, I'll do my best to implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants