@@ -701,20 +701,17 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
701
701
& self ,
702
702
mut from : Vec < TableWithJoins > ,
703
703
planner_context : & mut PlannerContext ,
704
- outer_query_schema : Option < & DFSchema > ,
705
704
) -> Result < LogicalPlan > {
706
705
match from. len ( ) {
707
706
0 => Ok ( LogicalPlanBuilder :: empty ( true ) . build ( ) ?) ,
708
707
1 => {
709
708
let from = from. remove ( 0 ) ;
710
- self . plan_table_with_joins ( from, planner_context, outer_query_schema )
709
+ self . plan_table_with_joins ( from, planner_context)
711
710
}
712
711
_ => {
713
712
let plans = from
714
713
. into_iter ( )
715
- . map ( |t| {
716
- self . plan_table_with_joins ( t, planner_context, outer_query_schema)
717
- } )
714
+ . map ( |t| self . plan_table_with_joins ( t, planner_context) )
718
715
. collect :: < Result < Vec < _ > > > ( ) ?;
719
716
let mut left = plans[ 0 ] . clone ( ) ;
720
717
for right in plans. iter ( ) . skip ( 1 ) {
@@ -729,16 +726,14 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
729
726
& self ,
730
727
t : TableWithJoins ,
731
728
planner_context : & mut PlannerContext ,
732
- outer_query_schema : Option < & DFSchema > ,
733
729
) -> Result < LogicalPlan > {
734
730
// From clause may exist CTEs, we should separate them from global CTEs.
735
731
// CTEs in from clause are allowed to be duplicated.
736
732
// Such as `select * from (WITH source AS (select 1 as e) SELECT * FROM source) t1, (WITH source AS (select 1 as e) SELECT * FROM source) t2;` which is valid.
737
733
// So always use original global CTEs to plan CTEs in from clause.
738
734
// Btw, don't need to add CTEs in from to global CTEs.
739
735
let origin_planner_context = planner_context. clone ( ) ;
740
- let left =
741
- self . create_relation ( t. relation , planner_context, outer_query_schema) ?;
736
+ let left = self . create_relation ( t. relation , planner_context) ?;
742
737
match t. joins . len ( ) {
743
738
0 => {
744
739
* planner_context = origin_planner_context;
@@ -751,16 +746,10 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
751
746
left,
752
747
joins. next ( ) . unwrap ( ) , // length of joins > 0
753
748
planner_context,
754
- outer_query_schema,
755
749
) ?;
756
750
for join in joins {
757
751
* planner_context = origin_planner_context. clone ( ) ;
758
- left = self . parse_relation_join (
759
- left,
760
- join,
761
- planner_context,
762
- outer_query_schema,
763
- ) ?;
752
+ left = self . parse_relation_join ( left, join, planner_context) ?;
764
753
}
765
754
* planner_context = origin_planner_context;
766
755
Ok ( left)
@@ -773,10 +762,8 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
773
762
left : LogicalPlan ,
774
763
join : Join ,
775
764
planner_context : & mut PlannerContext ,
776
- outer_query_schema : Option < & DFSchema > ,
777
765
) -> Result < LogicalPlan > {
778
- let right =
779
- self . create_relation ( join. relation , planner_context, outer_query_schema) ?;
766
+ let right = self . create_relation ( join. relation , planner_context) ?;
780
767
match join. join_operator {
781
768
JoinOperator :: LeftOuter ( constraint) => {
782
769
self . parse_join ( left, right, constraint, JoinType :: Left , planner_context)
@@ -914,7 +901,6 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
914
901
& self ,
915
902
relation : TableFactor ,
916
903
planner_context : & mut PlannerContext ,
917
- outer_query_schema : Option < & DFSchema > ,
918
904
) -> Result < LogicalPlan > {
919
905
let ( plan, alias) = match relation {
920
906
TableFactor :: Table { name, alias, .. } => {
@@ -946,11 +932,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
946
932
table_with_joins,
947
933
alias,
948
934
} => (
949
- self . plan_table_with_joins (
950
- * table_with_joins,
951
- planner_context,
952
- outer_query_schema,
953
- ) ?,
935
+ self . plan_table_with_joins ( * table_with_joins, planner_context) ?,
954
936
alias,
955
937
) ,
956
938
// @todo Support TableFactory::TableFunction?
@@ -1095,9 +1077,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
1095
1077
}
1096
1078
1097
1079
// process `from` clause
1098
- let plan =
1099
- self . plan_from_tables ( select. from , planner_context, outer_query_schema) ?;
1100
-
1080
+ let plan = self . plan_from_tables ( select. from , planner_context) ?;
1101
1081
let empty_from = matches ! ( plan, LogicalPlan :: EmptyRelation ( _) ) ;
1102
1082
// build from schema for unqualifier column ambiguous check
1103
1083
// we should get only one field for unqualifier column from schema.
0 commit comments