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 PartiQL bitwise operators #1221

Open
5 tasks
am357 opened this issue Sep 20, 2023 · 0 comments
Open
5 tasks

Implement PartiQL bitwise operators #1221

am357 opened this issue Sep 20, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@am357
Copy link
Contributor

am357 commented Sep 20, 2023

Relevant Issue/Bug

  • N/A

Requested Solution/Feature

  • Add support for bitwise operators in PartiQL:
Operator Description Example Result
|| concatenation B'10001' || B'011' 10001011
& bitwise AND B'10001' & B'01101' 00001
| bitwise OR B'10001' | B'01101' 11101
# bitwise XOR B'10001' # B'01101' 11100
~ bitwise NOT ~ B'10001' 01110
<< bitwise shift left B'10001' << 3 01000
>> bitwise shift right B'10001' >> 2 00100
-- PostgresSQL: https://www.db-fiddle.com/f/g952RU7t652W32aiuWvsk6/8

SELECT B'110' | B'101' AS bit_or;
-- output: 111

SELECT 30 & 199 & 7 AS bit_and;
-- output: 6

Describe Alternatives

  • We could use a custom function for this with the following sample signatures for the immediate narrow use-case:
INT -> INT -> INT // E.g., bit_and(2, 3)
INT -> INT -> INT -> INT // E.g., bit_and(2, 3, 4)

Additional Context

Prior Art:

  1. PostgresSQL
  2. SQLite
  3. MySQL
  4. SQLServer

DoD (Definition of Done)

  • The required types are implemented
  • The operator precedence is determined and documented in partiql-doc or partiql-spec
  • The implementation is merged to main
  • The conformance tests are created
  • Mini RFC?
@am357 am357 added the enhancement New feature or request label Sep 20, 2023
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

No branches or pull requests

1 participant