Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ea-rus committed Nov 2, 2024
1 parent 29ab045 commit c225895
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions mindsdb_sql/planner/query_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ def find_predictors(node, is_table, **kwargs):

elif column.name is not None:
# is Identifier
if isinstance(column.name, ast.Star):
continue
col_name = column.name.upper()
if column.table is not None:
table = column.table
Expand Down
33 changes: 32 additions & 1 deletion tests/test_planner/test_join_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,4 +489,35 @@ def test_join_one_integration(self):
)
plan = plan_query(query, integrations=['int'], default_namespace='int')

assert plan.steps == expected_plan.steps
assert plan.steps == expected_plan.steps

def test_cte(self):
query = parse_sql('''
with t1 as (
select * from int1.tbl1
)
select t1.id, t2.* from t1
join int2.tbl2 t2 on t1.id>t2.id
''')

subquery = copy.deepcopy(query)
subquery.from_table = None

plan = plan_query(query, integrations=['int1', 'int2'], default_namespace='mindsdb')

expected_plan = QueryPlan(
steps=[
FetchDataframeStep(integration='int1', query=parse_sql('select * from tbl1')),
SubSelectStep(dataframe=Result(0), query=Select(targets=[Star()]), table_name='t1'),
FetchDataframeStep(integration='int2', query=parse_sql('select * from tbl2 as t2')),
JoinStep(left=Result(1),
right=Result(2),
query=Join(left=Identifier('tab1'),
right=Identifier('tab2'),
condition=BinaryOperation(op='>', args=[Identifier('t1.id'), Identifier('t2.id')]),
join_type=JoinType.JOIN)),
QueryStep(parse_sql('SELECT t1.`id`, t2.*'), from_table=Result(3)),
]
)

assert plan.steps == expected_plan.steps

0 comments on commit c225895

Please sign in to comment.