feat(snowflake)!: support transpilation of BITSHIFTLEFT and BITSHIFTRIGHT#6586
feat(snowflake)!: support transpilation of BITSHIFTLEFT and BITSHIFTRIGHT#6586georgesittas merged 19 commits intomainfrom
Conversation
SQLGlot Integration Test ResultsComparing:
By Dialect
Overallmain: 5697 total, 5429 passed (pass rate: 95.3%), sqlglot version: sqlglot:feature/transpile-bitshift: 5697 total, 5429 passed (pass rate: 95.3%), sqlglot version: Difference: No change |
georgesittas
left a comment
There was a problem hiding this comment.
This needs testing, but I'm skeptical about the approach. May need to sync in Slack about this.
@georgesittas Please see the Jira ticket for all tests that were run prior to the first push. There's about 300 test queries against Snowflake, transpiled, run against DuckDB and results checked against one another. |
|
We need to add tests. |
9f96195 to
21052b5
Compare
21052b5 to
7c4b5e3
Compare
83f7591 to
526cd22
Compare
|
@fivetran-kwoodbeck @VaggelisD take a look at the refactored PR when you get the chance, took a stab at cleaning it up a bit. |
VaggelisD
left a comment
There was a problem hiding this comment.
Only got one question, @fivetran-kwoodbeck if the refactored logic & tests check out feel free to merge
|
Hi @VaggelisD The tests don't pass and I'm not sure what's the best way to deal with it (a lot of back and forth). There are 2 issues, both of which can be seen here: The first is I think it needs an Which I think can be solved with an extra |
526cd22 to
bc2170a
Compare
georgesittas
left a comment
There was a problem hiding this comment.
A few more comments, but should be good to go soon.
a90a7e7 to
4bd8cc5
Compare
…DB with INT128 casts and precedence fixes
52ccc48 to
72741a9
Compare
There was a problem hiding this comment.
Hey @fivetran-kwoodbeck, thank you for the patience on this one. I'll just get it in and apply any last minor changes to take it to the finish line. Nice work 👍
|
Commit for reference: faa4696. |
DuckDB has support for left and right shift (<< and >>) up to INT128, but by default it assumes INT32 and needs casting in order to prevent it from throwing errors in various situations. See the Jira tickets for full testing.
Snowflake claims it always returns an INT128 (for INT input). In practice, it scales based on result and ranges from NUMBER(3,0) to NUMBER(38,0) depending on what number is returned. Snowflake also supports BINARY input.
Snowflake does not throw errors when you shift over the max int, DuckDB does.
Documentation:
https://docs.snowflake.com/en/sql-reference/functions/bitshiftleft
https://docs.snowflake.com/en/sql-reference/functions/bitshiftright