@@ -1117,8 +1117,6 @@ impl LogicalPlanBuilder {
11171117 . collect :: < Result < _ > > ( ) ?;
11181118
11191119 let on: Vec < ( _ , _ ) > = left_keys. into_iter ( ) . zip ( right_keys) . collect ( ) ;
1120- let join_schema =
1121- build_join_schema ( self . plan . schema ( ) , right. schema ( ) , & join_type) ?;
11221120 let mut join_on: Vec < ( Expr , Expr ) > = vec ! [ ] ;
11231121 let mut filters: Option < Expr > = None ;
11241122 for ( l, r) in & on {
@@ -1151,33 +1149,33 @@ impl LogicalPlanBuilder {
11511149 DataFusionError :: Internal ( "filters should not be None here" . to_string ( ) )
11521150 } ) ?)
11531151 } else {
1154- Ok ( Self :: new ( LogicalPlan :: Join ( Join {
1155- left : self . plan ,
1156- right : Arc :: new ( right) ,
1157- on : join_on,
1158- filter : filters,
1152+ let join = Join :: try_new (
1153+ self . plan ,
1154+ Arc :: new ( right) ,
1155+ join_on,
1156+ filters,
11591157 join_type,
1160- join_constraint : JoinConstraint :: Using ,
1161- schema : DFSchemaRef :: new ( join_schema) ,
1162- null_equals_null : false ,
1163- } ) ) )
1158+ JoinConstraint :: Using ,
1159+ false ,
1160+ ) ?;
1161+
1162+ Ok ( Self :: new ( LogicalPlan :: Join ( join) ) )
11641163 }
11651164 }
11661165
11671166 /// Apply a cross join
11681167 pub fn cross_join ( self , right : LogicalPlan ) -> Result < Self > {
1169- let join_schema =
1170- build_join_schema ( self . plan . schema ( ) , right. schema ( ) , & JoinType :: Inner ) ?;
1171- Ok ( Self :: new ( LogicalPlan :: Join ( Join {
1172- left : self . plan ,
1173- right : Arc :: new ( right) ,
1174- on : vec ! [ ] ,
1175- filter : None ,
1176- join_type : JoinType :: Inner ,
1177- join_constraint : JoinConstraint :: On ,
1178- null_equals_null : false ,
1179- schema : DFSchemaRef :: new ( join_schema) ,
1180- } ) ) )
1168+ let join = Join :: try_new (
1169+ self . plan ,
1170+ Arc :: new ( right) ,
1171+ vec ! [ ] ,
1172+ None ,
1173+ JoinType :: Inner ,
1174+ JoinConstraint :: On ,
1175+ false ,
1176+ ) ?;
1177+
1178+ Ok ( Self :: new ( LogicalPlan :: Join ( join) ) )
11811179 }
11821180
11831181 /// Repartition
@@ -1338,7 +1336,7 @@ impl LogicalPlanBuilder {
13381336 /// to columns from the existing input. `r`, the second element of the tuple,
13391337 /// must only refer to columns from the right input.
13401338 ///
1341- /// `filter` contains any other other filter expression to apply during the
1339+ /// `filter` contains any other filter expression to apply during the
13421340 /// join. Note that `equi_exprs` predicates are evaluated more efficiently
13431341 /// than the filter expressions, so they are preferred.
13441342 pub fn join_with_expr_keys (
@@ -1388,19 +1386,17 @@ impl LogicalPlanBuilder {
13881386 } )
13891387 . collect :: < Result < Vec < _ > > > ( ) ?;
13901388
1391- let join_schema =
1392- build_join_schema ( self . plan . schema ( ) , right. schema ( ) , & join_type) ?;
1393-
1394- Ok ( Self :: new ( LogicalPlan :: Join ( Join {
1395- left : self . plan ,
1396- right : Arc :: new ( right) ,
1397- on : join_key_pairs,
1389+ let join = Join :: try_new (
1390+ self . plan ,
1391+ Arc :: new ( right) ,
1392+ join_key_pairs,
13981393 filter,
13991394 join_type,
1400- join_constraint : JoinConstraint :: On ,
1401- schema : DFSchemaRef :: new ( join_schema) ,
1402- null_equals_null : false ,
1403- } ) ) )
1395+ JoinConstraint :: On ,
1396+ false ,
1397+ ) ?;
1398+
1399+ Ok ( Self :: new ( LogicalPlan :: Join ( join) ) )
14041400 }
14051401
14061402 /// Unnest the given column.
0 commit comments