Skip to content

Commit f5f35c6

Browse files
committed
fix(ir): ensure that join projection columns are all always nullable
1 parent b7f650c commit f5f35c6

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

ibis/expr/operations/relations.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import pandas as pd
2828
import pyarrow as pa
2929

30+
import ibis.expr.types as ir
31+
3032

3133
_table_names = (f"unbound_table_{i:d}" for i in itertools.count())
3234

@@ -658,7 +660,7 @@ def schema(self):
658660
return backend._get_schema_using_query(self.query)
659661

660662

661-
def _dedup_join_columns(expr, lname: str, rname: str):
663+
def _dedup_join_columns(expr: ir.Table, lname: str, rname: str):
662664
from ibis.expr.operations.generic import TableColumn
663665
from ibis.expr.operations.logical import Equals
664666

@@ -692,18 +694,22 @@ def _dedup_join_columns(expr, lname: str, rname: str):
692694
# Rename columns in the left table that overlap, unless they're known to be
693695
# equal to a column in the right
694696
left_projections = [
695-
left[column].name(lname.format(name=column) if lname else column)
697+
left[column]
698+
.cast(left[column].type().copy(nullable=True))
699+
.name(lname.format(name=column) if lname else column)
696700
if column in overlap and column not in equal
697-
else left[column]
701+
else left[column].cast(left[column].type().copy(nullable=True)).name(column)
698702
for column in left.columns
699703
]
700704

701705
# Rename columns in the right table that overlap, dropping any columns that
702706
# are known to be equal to those in the left table
703707
right_projections = [
704-
right[column].name(rname.format(name=column) if rname else column)
708+
right[column]
709+
.cast(right[column].type().copy(nullable=True))
710+
.name(rname.format(name=column) if rname else column)
705711
if column in overlap
706-
else right[column]
712+
else right[column].cast(right[column].type().copy(nullable=True)).name(column)
707713
for column in right.columns
708714
if column not in equal
709715
]

0 commit comments

Comments
 (0)