Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

chore: refactor IsNullOp and NotNullOp logic to make scalar ops generation easier#1822

Merged
tswast merged 31 commits intomainfrom
refactor-isnull-op
Aug 7, 2025
Merged

chore: refactor IsNullOp and NotNullOp logic to make scalar ops generation easier#1822
tswast merged 31 commits intomainfrom
refactor-isnull-op

Conversation

@tswast
Copy link
Copy Markdown
Contributor

@tswast tswast commented Jun 13, 2025

This change consolidates the definition and compilation logic for IsNullOp, isnull_op, NotNullOp, and notnull_op into a new, dedicated file: bigframes/operations/isnull_op.py.

Key changes include:

  • Moved operator definitions from generic_ops.py to isnull_op.py.
  • Moved Ibis scalar compilation logic from scalar_op_compiler.py to isnull_op.py.
  • Moved Polars expression compilation logic from polars/compiler.py to isnull_op.py.
  • Updated main compilers (ScalarOpCompiler and PolarsExpressionCompiler) to directly import and register the compilation functions from isnull_op.py.
  • Ensured all internal references and naming conventions (IsNullOp, isnull_op, NotNullOp, notnull_op) are consistent with the refactored structure.

NOTE: I was unable to perform test validation (unit and system) due to missing project-specific dependencies, primarily bigframes_vendored and test_utils.prefixer. The changes are provided based on the completion of the refactoring steps as you requested.

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> 🦕

This change consolidates the definition and compilation logic for IsNullOp, isnull_op, NotNullOp, and notnull_op into a new, dedicated file: `bigframes/operations/isnull_op.py`.

Key changes include:
- Moved operator definitions from `generic_ops.py` to `isnull_op.py`.
- Moved Ibis scalar compilation logic from `scalar_op_compiler.py` to `isnull_op.py`.
- Moved Polars expression compilation logic from `polars/compiler.py` to `isnull_op.py`.
- Updated main compilers (`ScalarOpCompiler` and `PolarsExpressionCompiler`) to directly import and register the compilation functions from `isnull_op.py`.
- Ensured all internal references and naming conventions (`IsNullOp`, `isnull_op`, `NotNullOp`, `notnull_op`) are consistent with the refactored structure.

NOTE: I was unable to perform test validation (unit and system) due to missing project-specific dependencies, primarily `bigframes_vendored` and `test_utils.prefixer`. The changes are provided based on the completion of the refactoring steps as you requested.
@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 Jun 13, 2025
Comment thread bigframes/core/compile/polars/compiler.py Outdated
Comment thread bigframes/operations/isnull_op.py Outdated
Comment thread bigframes/dataframe.py Outdated
Comment thread bigframes/core/compile/scalar_op_compiler.py Outdated
@product-auto-label product-auto-label Bot added size: xl Pull request size is extra large. and removed size: m Pull request size is medium. labels Jul 8, 2025
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The /io/ in the file path was messing up numpy in local pytest tests/system/small.

@tswast tswast marked this pull request as ready for review July 8, 2025 17:11
@tswast tswast requested review from a team and chelsea-lin July 8, 2025 17:11
Comment on lines +44 to +48
def _ibis_isnull_op_impl(x: ibis_types.Value):
return x.isnull()


scalar_op_compiler.scalar_op_compiler.register_unary_op(isnull_op)(_ibis_isnull_op_impl)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Discussed offline. Rather than combine this here, splitting up the scalar_op_compiler into multiple files would avoid the inversion and circular import problems.

@product-auto-label product-auto-label Bot added size: l Pull request size is large. and removed size: xl Pull request size is extra large. labels Jul 14, 2025
Comment thread bigframes/core/compile/compiled.py Outdated
Comment thread bigframes/core/compile/polars/operations/__init__.py Outdated
TrevorBergeron
TrevorBergeron previously approved these changes Aug 6, 2025
Comment thread bigframes/core/compile/ibis_compiler/operations/__init__.py Outdated
TrevorBergeron
TrevorBergeron previously approved these changes Aug 6, 2025
TrevorBergeron
TrevorBergeron previously approved these changes Aug 6, 2025
@tswast tswast enabled auto-merge (squash) August 6, 2025 18:09
@tswast tswast disabled auto-merge August 6, 2025 18:09
@product-auto-label product-auto-label Bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Aug 6, 2025
@tswast tswast enabled auto-merge (squash) August 7, 2025 02:56
@tswast tswast requested a review from TrevorBergeron August 7, 2025 02:56
@tswast
Copy link
Copy Markdown
Contributor Author

tswast commented Aug 7, 2025

Notebook failure is FAILED notebooks/location/regionalized.ipynb::regionalized.ipynb Seems unrelated.

@tswast tswast merged commit 4ea0e90 into main Aug 7, 2025
24 of 25 checks passed
@tswast tswast deleted the refactor-isnull-op branch August 7, 2025 16:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: xl Pull request size is extra large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants