Skip to content

Commit 7ef667b

Browse files
authored
fix: avoid ibis fillna warning in compiler (#2113)
* fix: avoid ibis fillna warning in compiler * fix mypy
1 parent caa824a commit 7ef667b

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

bigframes/core/compile/default_ordering.py renamed to bigframes/core/compile/ibis_compiler/default_ordering.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ def _convert_to_nonnull_string(column: ibis_types.Value) -> ibis_types.StringVal
4747
result = ibis_ops.ToJsonString(column).to_expr() # type: ignore
4848
# Escape backslashes and use backslash as delineator
4949
escaped = cast(
50-
ibis_types.StringColumn,
51-
result.fill_null(ibis_types.literal(""))
52-
if hasattr(result, "fill_null")
53-
else result.fillna(""),
50+
ibis_types.StringColumn, result.fill_null(ibis_types.literal(""))
5451
).replace(
5552
"\\", # type: ignore
5653
"\\\\", # type: ignore

bigframes/core/compile/ibis_compiler/scalar_op_registry.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import pandas as pd
2929

3030
from bigframes.core.compile.constants import UNIT_TO_US_CONVERSION_FACTORS
31-
import bigframes.core.compile.default_ordering
31+
import bigframes.core.compile.ibis_compiler.default_ordering
3232
from bigframes.core.compile.ibis_compiler.scalar_op_compiler import (
3333
scalar_op_compiler, # TODO(tswast): avoid import of variables
3434
)
@@ -1064,7 +1064,7 @@ def isin_op_impl(x: ibis_types.Value, op: ops.IsInOp):
10641064
if op.match_nulls and contains_nulls:
10651065
return x.isnull() | x.isin(matchable_ibis_values)
10661066
else:
1067-
return x.isin(matchable_ibis_values).fillna(False)
1067+
return x.isin(matchable_ibis_values).fill_null(ibis.literal(False))
10681068

10691069

10701070
@scalar_op_compiler.register_unary_op(ops.ToDatetimeOp, pass_op=True)
@@ -1383,8 +1383,8 @@ def eq_nulls_match_op(
13831383
left = x.cast(ibis_dtypes.str).fill_null(literal)
13841384
right = y.cast(ibis_dtypes.str).fill_null(literal)
13851385
else:
1386-
left = x.cast(ibis_dtypes.str).fillna(literal)
1387-
right = y.cast(ibis_dtypes.str).fillna(literal)
1386+
left = x.cast(ibis_dtypes.str).fill_null(literal)
1387+
right = y.cast(ibis_dtypes.str).fill_null(literal)
13881388

13891389
return left == right
13901390

@@ -1813,7 +1813,7 @@ def fillna_op(
18131813
if hasattr(x, "fill_null"):
18141814
return x.fill_null(typing.cast(ibis_types.Scalar, y))
18151815
else:
1816-
return x.fillna(typing.cast(ibis_types.Scalar, y))
1816+
return x.fill_null(typing.cast(ibis_types.Scalar, y))
18171817

18181818

18191819
@scalar_op_compiler.register_binary_op(ops.round_op)
@@ -2016,7 +2016,7 @@ def _construct_prompt(
20162016

20172017
@scalar_op_compiler.register_nary_op(ops.RowKey, pass_op=True)
20182018
def rowkey_op_impl(*values: ibis_types.Value, op: ops.RowKey) -> ibis_types.Value:
2019-
return bigframes.core.compile.default_ordering.gen_row_key(values)
2019+
return bigframes.core.compile.ibis_compiler.default_ordering.gen_row_key(values)
20202020

20212021

20222022
# Helpers

bigframes/session/_io/bigquery/read_gbq_table.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,9 @@
2727
import google.api_core.exceptions
2828
import google.cloud.bigquery as bigquery
2929

30-
import bigframes.clients
31-
import bigframes.core.compile
32-
import bigframes.core.compile.default_ordering
3330
import bigframes.core.sql
34-
import bigframes.dtypes
3531
import bigframes.exceptions as bfe
3632
import bigframes.session._io.bigquery
37-
import bigframes.session.clients
38-
import bigframes.version
3933

4034
# Avoid circular imports.
4135
if typing.TYPE_CHECKING:

tests/unit/test_notebook.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import pathlib
1516

16-
import os.path
17+
REPO_ROOT = pathlib.Path(__file__).parent.parent.parent
1718

1819

1920
def test_template_notebook_exists():
2021
# This notebook is meant for being used as a BigFrames usage template and
2122
# could be dynamically linked in places such as BQ Studio and IDE extensions.
2223
# Let's make sure it exists in the well known path.
23-
assert os.path.exists("notebooks/getting_started/bq_dataframes_template.ipynb")
24+
assert (
25+
REPO_ROOT / "notebooks" / "getting_started" / "bq_dataframes_template.ipynb"
26+
).exists()

0 commit comments

Comments
 (0)