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

Changed SnowflakeDialect flag div_is_floor_div to False #545

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sfc-gh-jmartinezramirez
Copy link

@sfc-gh-jmartinezramirez sfc-gh-jmartinezramirez commented Nov 19, 2024

Please answer these questions before submitting your pull requests. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-1812881: Division broken #543

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am adding new credentials
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

    The default behavior of the flag div_is_floor_div was changed to False. This ensures that Python and Snowflake operators match the right division.

@jochenott
Copy link

Looks good. You might want to enable these sqlalchemy-provided tests again, which I believe should pass now:
https://github.com/snowflakedb/snowflake-sqlalchemy/blob/main/tests/sqlalchemy_test_suite/test_suite_20.py#L84-L99

- v1.7.0(November 22, 2024)
- (Unreleased)
- Added `force_div_is_floordiv` flag to override `div_is_floordiv` new default value `False` in `SnowflakeDialect`.
- With the flag in `False`, the `/` division operator will be treated as a float division and `//` as a floor division.
Copy link

@jochenott jochenott Nov 22, 2024

Choose a reason for hiding this comment

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

This is not how it works.

This flag is a signal from the dialect towards sqlalchemy that describes the behavior of this sql implementation (Snowflake). So if select 4/5 returns 0, div_is_floordiv must be set to True. If it returns 0.8, this flag must be set to False.

So the previous value of div_is_floordiv = True for snowflake was just a bug, which should be fixed. Just as for other bugs, there is no need to make this configurable.

Choose a reason for hiding this comment

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

Hi @jochenott

We agree that the correct value for the flag div_is_floordiv in Snowflake should be False. However, current users expect the / and // operators to work as true divisions, although / should behave as a true division and // as a floor division. That's why the behavioral change will be introduced as a flag, which will be removed in a future major release.

Thank you for pointing out this code issue and your contribution!!!

@sfc-gh-jmartinezramirez sfc-gh-jmartinezramirez force-pushed the SNOW-1812881-division branch 2 times, most recently from 24dc195 to 2d4f27c Compare November 22, 2024 15:04
…that will be introduce, using new flag force_div_floordiv allow to test the new division behavior.

Update sa14:scripts to ignore feature_v20 from execution
Added tests to validate results of true and floor divisions using `force_div_is_floordiv` flag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SNOW-1812881: Division broken
5 participants