Skip to content

Commit ef30b12

Browse files
committed
testing fixes
1 parent 589b1f0 commit ef30b12

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

mindsdb_sql/planner/plan_join.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -480,36 +480,39 @@ def _check_conditions(node, **kwargs):
480480
if isinstance(arg2, Constant):
481481
conditions.append(node)
482482
elif table2 is not None:
483-
node.args = [arg1, arg2]
484-
node = copy.deepcopy(node)
485-
data_conditions.append(node)
483+
data_conditions.append([arg1, arg2])
486484

487485
query_traversal(fetch_table.join_condition, _check_conditions)
488486

489487
binary_ops.discard('and')
490488
if len(binary_ops) > 0:
491489
# other operations exists, skip
492-
return
490+
return []
493491

494-
for condition in data_conditions:
492+
for arg1, arg2 in data_conditions:
495493
# is fetched?
496-
arg1, arg2 = condition.args
497494
table2 = self.get_table_for_column(arg2)
498495
fetch_step = self.tables_fetch_step.get(table2.index)
499496

500497
if fetch_step is None:
501498
continue
502499

503500
# extract distinct values
504-
# remove alias
505-
arg2.parts = arg2.parts[-1:]
501+
# remove aliases
502+
arg1 = Identifier(parts=[arg1.parts[-1]])
503+
arg2 = Identifier(parts=[arg2.parts[-1]])
504+
506505
query2 = Select(targets=[arg2], distinct=True)
507506
subselect_step = SubSelectStep(query2, fetch_step.result)
508507
subselect_step = self.add_plan_step(subselect_step)
509508

510-
condition.args[1] = Parameter(subselect_step.result)
511-
condition.op = 'in'
512-
conditions.append(condition)
509+
conditions.append(BinaryOperation(
510+
op='in',
511+
args=[
512+
arg1,
513+
Parameter(subselect_step.result)
514+
]
515+
))
513516

514517
return conditions
515518

0 commit comments

Comments
 (0)