@@ -554,7 +554,7 @@ def test_select_from_table_subselect_api_integration(self):
554554 plan = plan_query (
555555 query ,
556556 integrations = [{'name' : 'int1' , 'class_type' : 'api' , 'type' : 'data' }],
557- predictor_metadata = [{'name' : 'pred' , 'integration_name' : 'mindsdb' }]
557+ predictor_metadata = [{'name' : 'pred' , 'integration_name' : 'mindsdb' }],
558558 )
559559
560560 assert plan .steps == expected_plan .steps
@@ -583,6 +583,47 @@ def test_select_from_table_subselect_sql_integration(self):
583583
584584 assert plan .steps == expected_plan .steps
585585
586+ def test_select_from_single_integration (self ):
587+ sql_parsed = '''
588+ with tab2 as (
589+ select * from int1.tabl2
590+ )
591+ select x from tab2
592+ join int1.tab1 on 0=0
593+ where x1 in (select id from int1.tab1)
594+ limit 1
595+ '''
596+
597+ sql_integration = '''
598+ with tab2 as (
599+ select * from tabl2
600+ )
601+ select x from tab2
602+ join tab1 on 0=0
603+ where x1 in (select id as id from tab1)
604+ limit 1
605+ '''
606+ query = parse_sql (sql_parsed , dialect = 'mindsdb' )
607+
608+ expected_plan = QueryPlan (
609+ predictor_namespace = 'mindsdb' ,
610+ steps = [
611+ FetchDataframeStep (
612+ integration = 'int1' ,
613+ query = parse_sql (sql_integration ),
614+ ),
615+ ],
616+ )
617+
618+ plan = plan_query (
619+ query ,
620+ integrations = [{'name' : 'int1' , 'class_type' : 'sql' , 'type' : 'data' }],
621+ predictor_metadata = [{'name' : 'pred' , 'integration_name' : 'mindsdb' }],
622+ default_namespace = 'mindsdb' ,
623+ )
624+
625+ assert plan .steps == expected_plan .steps
626+
586627 def test_delete_from_table_subselect_api_integration (self ):
587628 query = parse_sql ('''
588629 delete from int1.tab1
0 commit comments