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 Column.isin()with empty list #2001

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

Conversation

NickFishr
Copy link
Contributor

@NickFishr NickFishr commented Jul 30, 2024

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

    Fixes SNOW-1565789

    Github Issue SNOW-1565789: Column.isin() fails with empty list #1999

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
      • If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am adding new credentials
    • I am adding a new dependency
    • If this is a new feature/behavior, I'm adding the Local Testing parity changes.
  3. Please describe how your code solves the related issue.

    This PR solves the problem that an incorrect SQL query gets generated if Column.isin() get called with an empty list (not None).

    I'm not sure if the place for handling this is chosen wisely. I've tried several other locations, e.g. handling empty lists or Nones in InExpression, but there are a few places that rely on InExpression.values being an iterable, so I picked Column.isin() which seems the place with the minimum impact.

    I've assumed that the expected result of an empty isin() would be an empty dataframe, following the logic that an intersection of any set with the empty set is again the empty set.
    And also since the following SQL queries give an empty table as result:

    select 1 as B where B in (select 1 as A where A > 1);
    select 1 as B where B in (null);
    

    I'd be glad if parts of this PR might be helpful, but I'm also aware that this could be a tricky issue, so take whatever is useful, no hard feelings.

@NickFishr NickFishr requested a review from a team as a code owner July 30, 2024 20:14
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.

1 participant