@@ -595,6 +595,17 @@ impl LogicalPlanBuilder {
595595 self . join_detailed ( right, join_type, join_keys, false )
596596 }
597597
598+ fn normalize (
599+ plan : & LogicalPlan ,
600+ column : impl Into < Column > + Clone ,
601+ ) -> Result < Column > {
602+ let schemas = plan. all_schemas ( ) ;
603+ let using_columns = plan. using_columns ( ) ?;
604+ column
605+ . into ( )
606+ . normalize_with_schemas ( & schemas, & using_columns)
607+ }
608+
598609 /// Apply a join with on constraint and specified null equality
599610 /// If null_equals_null is true then null == null, else null != null
600611 pub fn join_detailed (
@@ -633,7 +644,10 @@ impl LogicalPlanBuilder {
633644 match ( l_is_left, l_is_right, r_is_left, r_is_right) {
634645 ( _, Ok ( _) , Ok ( _) , _) => ( Ok ( r) , Ok ( l) ) ,
635646 ( Ok ( _) , _, _, Ok ( _) ) => ( Ok ( l) , Ok ( r) ) ,
636- _ => ( l. normalize ( & self . plan ) , r. normalize ( right) ) ,
647+ _ => (
648+ Self :: normalize ( & self . plan , l) ,
649+ Self :: normalize ( right, r) ,
650+ ) ,
637651 }
638652 }
639653 ( Some ( lr) , None ) => {
@@ -643,9 +657,12 @@ impl LogicalPlanBuilder {
643657 right. schema ( ) . field_with_qualified_name ( lr, & l. name ) ;
644658
645659 match ( l_is_left, l_is_right) {
646- ( Ok ( _) , _) => ( Ok ( l) , r. normalize ( right) ) ,
647- ( _, Ok ( _) ) => ( r. normalize ( & self . plan ) , Ok ( l) ) ,
648- _ => ( l. normalize ( & self . plan ) , r. normalize ( right) ) ,
660+ ( Ok ( _) , _) => ( Ok ( l) , Self :: normalize ( right, r) ) ,
661+ ( _, Ok ( _) ) => ( Self :: normalize ( & self . plan , r) , Ok ( l) ) ,
662+ _ => (
663+ Self :: normalize ( & self . plan , l) ,
664+ Self :: normalize ( right, r) ,
665+ ) ,
649666 }
650667 }
651668 ( None , Some ( rr) ) => {
@@ -655,22 +672,25 @@ impl LogicalPlanBuilder {
655672 right. schema ( ) . field_with_qualified_name ( rr, & r. name ) ;
656673
657674 match ( r_is_left, r_is_right) {
658- ( Ok ( _) , _) => ( Ok ( r) , l. normalize ( right) ) ,
659- ( _, Ok ( _) ) => ( l. normalize ( & self . plan ) , Ok ( r) ) ,
660- _ => ( l. normalize ( & self . plan ) , r. normalize ( right) ) ,
675+ ( Ok ( _) , _) => ( Ok ( r) , Self :: normalize ( right, l) ) ,
676+ ( _, Ok ( _) ) => ( Self :: normalize ( & self . plan , l) , Ok ( r) ) ,
677+ _ => (
678+ Self :: normalize ( & self . plan , l) ,
679+ Self :: normalize ( right, r) ,
680+ ) ,
661681 }
662682 }
663683 ( None , None ) => {
664684 let mut swap = false ;
665- let left_key =
666- l . clone ( ) . normalize ( & self . plan ) . or_else ( |_| {
685+ let left_key = Self :: normalize ( & self . plan , l . clone ( ) )
686+ . or_else ( |_| {
667687 swap = true ;
668- l . normalize ( right)
688+ Self :: normalize ( right, l )
669689 } ) ;
670690 if swap {
671- ( r . normalize ( & self . plan ) , left_key)
691+ ( Self :: normalize ( & self . plan , r ) , left_key)
672692 } else {
673- ( left_key, r . normalize ( right) )
693+ ( left_key, Self :: normalize ( right, r ) )
674694 }
675695 }
676696 }
@@ -705,11 +725,11 @@ impl LogicalPlanBuilder {
705725 let left_keys: Vec < Column > = using_keys
706726 . clone ( )
707727 . into_iter ( )
708- . map ( |c| c . into ( ) . normalize ( & self . plan ) )
728+ . map ( |c| Self :: normalize ( & self . plan , c ) )
709729 . collect :: < Result < _ > > ( ) ?;
710730 let right_keys: Vec < Column > = using_keys
711731 . into_iter ( )
712- . map ( |c| c . into ( ) . normalize ( right) )
732+ . map ( |c| Self :: normalize ( right, c ) )
713733 . collect :: < Result < _ > > ( ) ?;
714734
715735 let on: Vec < ( _ , _ ) > = left_keys. into_iter ( ) . zip ( right_keys. into_iter ( ) ) . collect ( ) ;
0 commit comments