Skip to content

feat: Add isin local execution impl #1993

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

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

feat: Add isin local execution impl #1993

wants to merge 3 commits into from

Conversation

TrevorBergeron
Copy link
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. labels Aug 14, 2025
@TrevorBergeron TrevorBergeron marked this pull request as ready for review August 14, 2025 20:54
@TrevorBergeron TrevorBergeron requested review from a team as code owners August 14, 2025 20:54
@TrevorBergeron TrevorBergeron requested a review from sycai August 14, 2025 20:54
tswast
tswast previously approved these changes Aug 14, 2025
@@ -1062,7 +1062,7 @@ def isin_op_impl(x: ibis_types.Value, op: ops.IsInOp):
if op.match_nulls and contains_nulls:
return x.isnull() | x.isin(matchable_ibis_values)
else:
return x.isin(matchable_ibis_values)
return x.isin(matchable_ibis_values).fillna(False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this change any existing behavior? Were we missing a test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, it looks like we were handling this higher up. removed that code, and now the op itself is purely non-null. also added a test

for val in expr.op.values:
# coercible, non-coercible
# float NaN/inf should be treated as distinct from 'true' null values
if cast(bool, pd.isna(val)) and not isinstance(val, float):
Copy link
Contributor

Choose a reason for hiding this comment

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

We can fold this into one statement:

match_nulls = cast(bool, pd.isna(val)) and not isinstance(val, float) and expr.op.match_nulls

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do to the elif statement, that wouldn't quite be the same

pass

new_isin = ops.IsInOp(tuple(new_values), match_nulls=False).as_expr(arg)
if match_nulls:
Copy link
Contributor

Choose a reason for hiding this comment

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

So whether we match nulls partially depends on the last values in expr.op.values? Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

arr = arr.rename_columns(
{old_name: new_names[i] for i, old_name in enumerate(col_ids)}
)
assert_equivalence_execution(arr.node, REFERENCE_ENGINE, engine)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: empty line above assertion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@TrevorBergeron TrevorBergeron requested review from tswast and sycai August 14, 2025 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants