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

fix(snowflake): manually construct quantile calls with WITHIN GROUP #8846

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

gforsyth
Copy link
Member

@gforsyth gforsyth commented Apr 1, 2024

The Snowflake SQLGlot dialect rewrites calls to percentile_cont to
include WITHIN GROUP (ORDER BY ...)
as per https://docs.snowflake.com/en/sql-reference/functions/percentile_cont
using the rule add_within_group_for_percentiles

If we have copy=False set in our call to compile, if there is more
than one quantile, the rewrite rule fails on the second pass because
of some mutation in the first pass. To avoid this error, we create the
expression with the within group included already and skip the (now
unneeded) rewrite rule.

Fixes #8768

The Snowflake SQLGlot dialect rewrites calls to `percentile_cont` to
include     WITHIN GROUP (ORDER BY ...)
as per https://docs.snowflake.com/en/sql-reference/functions/percentile_cont
using the rule `add_within_group_for_percentiles`

If we have copy=False set in our call to `compile`, if there is more
than one quantile, the rewrite rule fails on the second pass because
of some mutation in the first pass. To avoid this error, we create the
expression with the within group included already and skip the (now
unneeded) rewrite rule.
@gforsyth
Copy link
Member Author

gforsyth commented Apr 1, 2024

Snowflake tests are good, some funky formatting where I removed a few socket error messages

🐚 just test snowflake
bringing up nodes...
.x...xx....xx.......x..x..x..xxx.........x.......x.............x.xx....x.xx.x [  4%]
.xxxxxx....x..xx.....x......x....x.....xx............x.........x.x.x.x......x [  9%]
.......xx......x.......................x...................xx......x..x...... [ 14%]
.....x.....x....................s..x.....x......................xx........... [ 18%]
....x.x.x........x...x....x....x...x.....x..x..x........x.........x......xx... [ 23%]
....x......x....x...........x.......x...x.....x..x........................... [ 28%]
.x........x..........x..............x.............x..xx...x.xx.......x....... [ 32%]
............x.................x.xxx..x..............x...x.................... [ 37%]
.......x.x..x..xx.xx.........x..........x..............x..x.....x.x.......... [ 42%]
............x..................x..................xx................x........ [ 46%]
.....x.....x.....................x.............x......xx..................... [ 51%]
..............................x.x.........x..x..xxx.xxxxxxx.x.x...x.x.x..xxxx [ 56%]
x..xx...xxxxx.xxxx...x..xxx...xxx.xx..x.x.x.x.xx.xxxxx..x.xxx..xx.x........xx [ 61%]
xx....x.x...................x...............sx.............x..x........x...... [ 65%]
...........x.............................x................................... [ 70%]
....x.....................................xxxx.xxx.x.x..xx.....x......s...... [ 75%]
.x...x.....................x...............x.x.......x..........x...x.x....x. [ 79%]
.x......x....x....x...x.......x...x........x.............xx................... [ 84%]
............................x.x..................s........................... [ 89%]
.......................................x..................................... [ 94%]
...x..........x............................................................ [ 98%]
.....................                                                         [100%]
1404 passed, 4 skipped, 233 xfailed in 119.31s (0:01:59)

@cpcloud cpcloud added this to the 9.0 milestone Apr 12, 2024
@cpcloud cpcloud added snowflake The Snowflake backend bug Incorrect behavior inside of ibis labels Apr 12, 2024
@cpcloud cpcloud merged commit 261a544 into ibis-project:main Apr 12, 2024
89 of 90 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior inside of ibis snowflake The Snowflake backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: AttributeError: 'NoneType' object has no attribute 'pop'
2 participants