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(mssql): restore any, all and cumulative versions #8409

Merged
merged 2 commits into from
Feb 21, 2024

Conversation

gforsyth
Copy link
Member

Description of changes

I took a look through what sqlalchemy was generating for these failing
test cases and then reimplemented it using sqlglot.

Any and All:

  • Instead of logical or we do a Max(IIF(condition, 1, 0))
  • Instead of logical and we do a Min(IIF(condition, 1, 0))

Cumulative versions:

The cumulative versions work, but required an additional check in the
visit_Not node. MSSQL doesn't support doing IFF(MAX(IFF(... -- the
argument to IFF has to be a boolean and the Window function isn't
considered a boolean for some reason, so the outer conditional needs to
be a case statement.- fix(mssql): restore any, all and cumulative versions

  • fix(mssql): support aggregations with any/all

Issues closed

I took a look through what sqlalchemy was generating for these failing
test cases and then reimplemented it using sqlglot.

Any and All:
* Instead of `logical or` we do a `Max(IIF(condition, 1, 0))`
* Instead of `logical and` we do a `Min(IIF(condition, 1, 0))`

Cumulative versions:

The cumulative versions work, but required an additional check in the
`visit_Not` node. MSSQL doesn't support doing `IFF(MAX(IFF(...` -- the
argument to IFF has to be a boolean and the Window function isn't
considered a boolean for some reason, so the outer conditional needs to
be a case statement.
@gforsyth gforsyth added the mssql The Microsoft SQL Server backend label Feb 21, 2024
Copy link
Member

@jcrist jcrist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@gforsyth gforsyth merged commit 99a4022 into ibis-project:main Feb 21, 2024
76 checks passed
@gforsyth gforsyth deleted the mssql/any_all branch February 21, 2024 15:59
@cpcloud
Copy link
Member

cpcloud commented Feb 21, 2024

Wonderful, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mssql The Microsoft SQL Server backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

regression(mssql): investigate bringing back any/all and cumulative versions
3 participants