From d4504e9c04b420203266d5d40977aaac3ee86d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a?= Date: Wed, 24 Sep 2025 18:04:44 +0000 Subject: [PATCH 1/2] fix: avoid ibis fillna warning in compiler --- .../compile/{ => ibis_compiler}/default_ordering.py | 2 +- .../core/compile/ibis_compiler/scalar_op_registry.py | 12 ++++++------ bigframes/session/_io/bigquery/read_gbq_table.py | 6 ------ tests/unit/test_notebook.py | 7 +++++-- 4 files changed, 12 insertions(+), 15 deletions(-) rename bigframes/core/compile/{ => ibis_compiler}/default_ordering.py (98%) diff --git a/bigframes/core/compile/default_ordering.py b/bigframes/core/compile/ibis_compiler/default_ordering.py similarity index 98% rename from bigframes/core/compile/default_ordering.py rename to bigframes/core/compile/ibis_compiler/default_ordering.py index 1a1350cfd6..d0e9d55f68 100644 --- a/bigframes/core/compile/default_ordering.py +++ b/bigframes/core/compile/ibis_compiler/default_ordering.py @@ -50,7 +50,7 @@ def _convert_to_nonnull_string(column: ibis_types.Value) -> ibis_types.StringVal ibis_types.StringColumn, result.fill_null(ibis_types.literal("")) if hasattr(result, "fill_null") - else result.fillna(""), + else result.fill_null(""), ).replace( "\\", # type: ignore "\\\\", # type: ignore diff --git a/bigframes/core/compile/ibis_compiler/scalar_op_registry.py b/bigframes/core/compile/ibis_compiler/scalar_op_registry.py index a750a625ad..86a3091a4d 100644 --- a/bigframes/core/compile/ibis_compiler/scalar_op_registry.py +++ b/bigframes/core/compile/ibis_compiler/scalar_op_registry.py @@ -28,7 +28,7 @@ import pandas as pd from bigframes.core.compile.constants import UNIT_TO_US_CONVERSION_FACTORS -import bigframes.core.compile.default_ordering +import bigframes.core.compile.ibis_compiler.default_ordering from bigframes.core.compile.ibis_compiler.scalar_op_compiler import ( scalar_op_compiler, # TODO(tswast): avoid import of variables ) @@ -1064,7 +1064,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).fillna(False) + return x.isin(matchable_ibis_values).fill_null(False) @scalar_op_compiler.register_unary_op(ops.ToDatetimeOp, pass_op=True) @@ -1383,8 +1383,8 @@ def eq_nulls_match_op( left = x.cast(ibis_dtypes.str).fill_null(literal) right = y.cast(ibis_dtypes.str).fill_null(literal) else: - left = x.cast(ibis_dtypes.str).fillna(literal) - right = y.cast(ibis_dtypes.str).fillna(literal) + left = x.cast(ibis_dtypes.str).fill_null(literal) + right = y.cast(ibis_dtypes.str).fill_null(literal) return left == right @@ -1813,7 +1813,7 @@ def fillna_op( if hasattr(x, "fill_null"): return x.fill_null(typing.cast(ibis_types.Scalar, y)) else: - return x.fillna(typing.cast(ibis_types.Scalar, y)) + return x.fill_null(typing.cast(ibis_types.Scalar, y)) @scalar_op_compiler.register_binary_op(ops.round_op) @@ -2016,7 +2016,7 @@ def _construct_prompt( @scalar_op_compiler.register_nary_op(ops.RowKey, pass_op=True) def rowkey_op_impl(*values: ibis_types.Value, op: ops.RowKey) -> ibis_types.Value: - return bigframes.core.compile.default_ordering.gen_row_key(values) + return bigframes.core.compile.ibis_compiler.default_ordering.gen_row_key(values) # Helpers diff --git a/bigframes/session/_io/bigquery/read_gbq_table.py b/bigframes/session/_io/bigquery/read_gbq_table.py index 30a25762eb..00531ce25d 100644 --- a/bigframes/session/_io/bigquery/read_gbq_table.py +++ b/bigframes/session/_io/bigquery/read_gbq_table.py @@ -27,15 +27,9 @@ import google.api_core.exceptions import google.cloud.bigquery as bigquery -import bigframes.clients -import bigframes.core.compile -import bigframes.core.compile.default_ordering import bigframes.core.sql -import bigframes.dtypes import bigframes.exceptions as bfe import bigframes.session._io.bigquery -import bigframes.session.clients -import bigframes.version # Avoid circular imports. if typing.TYPE_CHECKING: diff --git a/tests/unit/test_notebook.py b/tests/unit/test_notebook.py index a41854fb29..3feacd52b2 100644 --- a/tests/unit/test_notebook.py +++ b/tests/unit/test_notebook.py @@ -12,12 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pathlib -import os.path +REPO_ROOT = pathlib.Path(__file__).parent.parent.parent def test_template_notebook_exists(): # This notebook is meant for being used as a BigFrames usage template and # could be dynamically linked in places such as BQ Studio and IDE extensions. # Let's make sure it exists in the well known path. - assert os.path.exists("notebooks/getting_started/bq_dataframes_template.ipynb") + assert ( + REPO_ROOT / "notebooks" / "getting_started" / "bq_dataframes_template.ipynb" + ).exists() From 74211defa8764690e673d2507e9c0fb95597d40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Swe=C3=B1a?= Date: Thu, 25 Sep 2025 15:38:46 +0000 Subject: [PATCH 2/2] fix mypy --- bigframes/core/compile/ibis_compiler/default_ordering.py | 5 +---- bigframes/core/compile/ibis_compiler/scalar_op_registry.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/bigframes/core/compile/ibis_compiler/default_ordering.py b/bigframes/core/compile/ibis_compiler/default_ordering.py index d0e9d55f68..3f2628d10c 100644 --- a/bigframes/core/compile/ibis_compiler/default_ordering.py +++ b/bigframes/core/compile/ibis_compiler/default_ordering.py @@ -47,10 +47,7 @@ def _convert_to_nonnull_string(column: ibis_types.Value) -> ibis_types.StringVal result = ibis_ops.ToJsonString(column).to_expr() # type: ignore # Escape backslashes and use backslash as delineator escaped = cast( - ibis_types.StringColumn, - result.fill_null(ibis_types.literal("")) - if hasattr(result, "fill_null") - else result.fill_null(""), + ibis_types.StringColumn, result.fill_null(ibis_types.literal("")) ).replace( "\\", # type: ignore "\\\\", # type: ignore diff --git a/bigframes/core/compile/ibis_compiler/scalar_op_registry.py b/bigframes/core/compile/ibis_compiler/scalar_op_registry.py index 86a3091a4d..8426a86375 100644 --- a/bigframes/core/compile/ibis_compiler/scalar_op_registry.py +++ b/bigframes/core/compile/ibis_compiler/scalar_op_registry.py @@ -1064,7 +1064,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).fill_null(False) + return x.isin(matchable_ibis_values).fill_null(ibis.literal(False)) @scalar_op_compiler.register_unary_op(ops.ToDatetimeOp, pass_op=True)