peter-toth commented on code in PR #42036:
URL: https://github.com/apache/spark/pull/42036#discussion_r1273159181


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala:
##########
@@ -887,6 +887,16 @@ case class WithCTE(plan: LogicalPlan, cteDefs: 
Seq[CTERelationDef]) extends Logi
   }
 }
 
+/**
+ * The logical node which is able to place the `WithCTE` node on its children.
+ */
+trait CTEInChildren extends LogicalPlan {
+  def withCTEDefs(cteDefs: Seq[CTERelationDef]): LogicalPlan = {
+    withNewChildren(children.map(WithCTE(_, cteDefs)))

Review Comment:
   I'm not sure that it is always fine to duplicate CTE relations into multiple 
childrens.
   For example, if we have a non-deterministic relation definition and 1-1 
reference to it in 2 childrens of `CTEInChildren` and then here we duplicate 
the relations into the 2 childrens then I think the `InlineCTE` rule will 
decide to inline the relation 2 times, which is not correct.
   But I agree with you, I don't see that this could happen now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to