Skip to content

Commit 0f20a6a

Browse files
committed
final cleanup
1 parent 294510f commit 0f20a6a

File tree

3 files changed

+11
-27
lines changed

3 files changed

+11
-27
lines changed

bigframes/core/expression.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -433,35 +433,24 @@ class ResolvedDerefOp(DerefOp):
433433
"""An expression that refers to a column by ID and resolved with schema bound."""
434434

435435
dtype: dtypes.Dtype
436-
nullable: bool = True
436+
is_nullable: bool
437437

438438
@classmethod
439439
def from_field(cls, f: field.Field):
440-
return cls(f.id, f.dtype, f.nullable)
440+
return cls(id=f.id, dtype=f.dtype, is_nullable=f.nullable)
441441

442442
@property
443443
def is_resolved(self) -> bool:
444444
return True
445445

446+
@property
447+
def nullable(self) -> bool:
448+
return self.is_nullable
449+
446450
@property
447451
def output_type(self) -> dtypes.ExpressionType:
448452
return self.dtype
449453

450-
def bind_variables(
451-
self, bindings: Mapping[str, Expression], allow_partial_bindings: bool = False
452-
) -> Expression:
453-
return self
454-
455-
def bind_refs(
456-
self,
457-
bindings: Mapping[ids.ColumnId, Expression],
458-
allow_partial_bindings: bool = False,
459-
) -> Expression:
460-
# TODO: Check if we can remove.
461-
if self.id in bindings.keys():
462-
return bindings[self.id]
463-
return self
464-
465454

466455
@dataclasses.dataclass(frozen=True)
467456
class OpExpression(Expression):

bigframes/core/rewrite/schema_binding.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
import dataclasses
16-
import typing
1716

1817
from bigframes.core import bigframe_node
1918
from bigframes.core import expression as ex
@@ -56,14 +55,8 @@ def bind_schema_to_node(
5655
if isinstance(node, nodes.JoinNode):
5756
conditions = tuple(
5857
(
59-
typing.cast(
60-
ex.ResolvedDerefOp,
61-
ex.bind_schema_fields(left, node.left_child.field_by_id),
62-
),
63-
typing.cast(
64-
ex.ResolvedDerefOp,
65-
ex.bind_schema_fields(right, node.right_child.field_by_id),
66-
),
58+
ex.ResolvedDerefOp.from_field(node.left_child.field_by_id[left.id]),
59+
ex.ResolvedDerefOp.from_field(node.right_child.field_by_id[right.id]),
6760
)
6861
for left, right in node.conditions
6962
)

tests/unit/core/test_expression.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def test_deref_op_dtype_resolution():
7777

7878

7979
def test_field_ref_expr_dtype_resolution_short_circuit():
80-
expression = ex.ResolvedDerefOp(id=ids.ColumnId("mycol"), dtype=dtypes.INT_DTYPE)
80+
expression = ex.ResolvedDerefOp(
81+
id=ids.ColumnId("mycol"), dtype=dtypes.INT_DTYPE, is_nullable=True
82+
)
8183
field_bindings = _create_field_bindings({"anotherCol": dtypes.STRING_DTYPE})
8284

8385
result = ex.bind_schema_fields(expression, field_bindings)

0 commit comments

Comments
 (0)