@@ -113,6 +113,15 @@ pub enum LogicalPlan {
113113 /// The output schema, containing fields from the left and right inputs
114114 schema : DFSchemaRef ,
115115 } ,
116+ /// Apply Cross Join to two logical plans
117+ CrossJoin {
118+ /// Left input
119+ left : Arc < LogicalPlan > ,
120+ /// Right input
121+ right : Arc < LogicalPlan > ,
122+ /// The output schema, containing fields from the left and right inputs
123+ schema : DFSchemaRef ,
124+ } ,
116125 /// Repartition the plan based on a partitioning scheme.
117126 Repartition {
118127 /// The incoming logical plan
@@ -203,6 +212,7 @@ impl LogicalPlan {
203212 LogicalPlan :: Aggregate { schema, .. } => & schema,
204213 LogicalPlan :: Sort { input, .. } => input. schema ( ) ,
205214 LogicalPlan :: Join { schema, .. } => & schema,
215+ LogicalPlan :: CrossJoin { schema, .. } => & schema,
206216 LogicalPlan :: Repartition { input, .. } => input. schema ( ) ,
207217 LogicalPlan :: Limit { input, .. } => input. schema ( ) ,
208218 LogicalPlan :: CreateExternalTable { schema, .. } => & schema,
@@ -229,6 +239,11 @@ impl LogicalPlan {
229239 right,
230240 schema,
231241 ..
242+ }
243+ | LogicalPlan :: CrossJoin {
244+ left,
245+ right,
246+ schema,
232247 } => {
233248 let mut schemas = left. all_schemas ( ) ;
234249 schemas. extend ( right. all_schemas ( ) ) ;
@@ -290,8 +305,9 @@ impl LogicalPlan {
290305 | LogicalPlan :: EmptyRelation { .. }
291306 | LogicalPlan :: Limit { .. }
292307 | LogicalPlan :: CreateExternalTable { .. }
293- | LogicalPlan :: Explain { .. } => vec ! [ ] ,
294- LogicalPlan :: Union { .. } => {
308+ | LogicalPlan :: CrossJoin { .. }
309+ | LogicalPlan :: Explain { .. }
310+ | LogicalPlan :: Union { .. } => {
295311 vec ! [ ]
296312 }
297313 }
@@ -307,6 +323,7 @@ impl LogicalPlan {
307323 LogicalPlan :: Aggregate { input, .. } => vec ! [ input] ,
308324 LogicalPlan :: Sort { input, .. } => vec ! [ input] ,
309325 LogicalPlan :: Join { left, right, .. } => vec ! [ left, right] ,
326+ LogicalPlan :: CrossJoin { left, right, .. } => vec ! [ left, right] ,
310327 LogicalPlan :: Limit { input, .. } => vec ! [ input] ,
311328 LogicalPlan :: Extension { node } => node. inputs ( ) ,
312329 LogicalPlan :: Union { inputs, .. } => inputs. iter ( ) . collect ( ) ,
@@ -396,7 +413,8 @@ impl LogicalPlan {
396413 LogicalPlan :: Repartition { input, .. } => input. accept ( visitor) ?,
397414 LogicalPlan :: Aggregate { input, .. } => input. accept ( visitor) ?,
398415 LogicalPlan :: Sort { input, .. } => input. accept ( visitor) ?,
399- LogicalPlan :: Join { left, right, .. } => {
416+ LogicalPlan :: Join { left, right, .. }
417+ | LogicalPlan :: CrossJoin { left, right, .. } => {
400418 left. accept ( visitor) ? && right. accept ( visitor) ?
401419 }
402420 LogicalPlan :: Union { inputs, .. } => {
@@ -669,6 +687,9 @@ impl LogicalPlan {
669687 keys. iter ( ) . map ( |( l, r) | format ! ( "{} = {}" , l, r) ) . collect ( ) ;
670688 write ! ( f, "Join: {}" , join_expr. join( ", " ) )
671689 }
690+ LogicalPlan :: CrossJoin { .. } => {
691+ write ! ( f, "CrossJoin:" )
692+ }
672693 LogicalPlan :: Repartition {
673694 partitioning_scheme,
674695 ..
0 commit comments