fix: allow IsInOp with same dtypes regardless nullable (#2466) · googleapis/python-bigquery-dataframes@1d81b41 · GitHub
Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 1d81b41

Browse files
authored
fix: allow IsInOp with same dtypes regardless nullable (#2466)
- Update Ibis isin_op_impl to compare types by name, allowing comparisons between columns and literals with different nullability. - Update SQLGlot IsInOp implementation to use dtypes.can_compare for more robust type compatibility checking. - Improve dtypes.can_compare to gracefully handle type coercion failures. - Migrate TPCH verification script to tests/system/large/test_tpch.py for better integration with the test suite. Fixes 485642936 🦕
1 parent 6306478 commit 1d81b41

5 files changed

Lines changed: 108 additions & 137 deletions

File tree

bigframes/core/compile/ibis_compiler/scalar_op_registry.py

Lines changed: 1 addition & 1 deletion

bigframes/core/compile/sqlglot/expressions/comparison_ops.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,11 @@
3333
@register_unary_op(ops.IsInOp, pass_op=True)
3434
def _(expr: TypedExpr, op: ops.IsInOp) -> sge.Expression:
3535
values = []
36-
is_numeric_expr = dtypes.is_numeric(expr.dtype, include_bool=False)
3736
for value in op.values:
3837
if _is_null(value):
3938
continue
4039
dtype = dtypes.bigframes_type(type(value))
41-
if (
42-
expr.dtype == dtype
43-
or is_numeric_expr
44-
and dtypes.is_numeric(dtype, include_bool=False)
45-
):
40+
if dtypes.can_compare(expr.dtype, dtype):
4641
values.append(sge.convert(value))
4742

4843
if op.match_nulls:

bigframes/dtypes.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,11 @@ def is_comparable(type_: ExpressionType) -> bool:
370370

371371

372372
def can_compare(type1: ExpressionType, type2: ExpressionType) -> bool:
373-
coerced_type = coerce_to_common(type1, type2)
374-
return is_comparable(coerced_type)
373+
try:
374+
coerced_type = coerce_to_common(type1, type2)
375+
return is_comparable(coerced_type)
376+
except TypeError:
377+
return False
375378

376379

377380
def get_struct_fields(type_: ExpressionType) -> dict[str, Dtype]:

scripts/tpch_result_verify.py

Lines changed: 0 additions & 128 deletions
This file was deleted.

tests/system/large/test_tpch.py

Lines changed: 101 additions & 0 deletions

0 commit comments

Comments
 (0)