cloud-fan commented on a change in pull request #33671:
URL: https://github.com/apache/spark/pull/33671#discussion_r687026727
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala
##########
@@ -625,7 +627,78 @@ case class With(child: LogicalPlan, cteRelations:
Seq[(String, SubqueryAlias)])
override def innerChildren: Seq[LogicalPlan] = cteRelations.map(_._2)
- override protected def withNewChildInternal(newChild: LogicalPlan): With =
copy(child = newChild)
+ override protected def withNewChildInternal(newChild: LogicalPlan):
UnresolvedWith =
+ copy(child = newChild)
+}
+
+/**
+ * A wrapper for CTE definition plan with a unique ID.
+ * @param child The CTE definition query plan.
+ * @param id The unique ID for this CTE definition.
+ */
+case class CTERelationDef(child: LogicalPlan, id: Long = CTERelationDef.newId)
extends UnaryNode {
+
+ final override val nodePatterns: Seq[TreePattern] = Seq(CTE)
+
+ override protected def withNewChildInternal(newChild: LogicalPlan):
LogicalPlan =
+ copy(child = newChild)
+
+ override def output: Seq[Attribute] = if (resolved) child.output else Nil
+}
+
+object CTERelationDef {
+ private val curId = new java.util.concurrent.atomic.AtomicLong()
+ def newId: Long = curId.getAndIncrement()
+}
+
+/**
+ * Represents the relation of a CTE reference.
+ * @param cteId The ID of the corresponding CTE definition.
+ * @param _resolved Whether this reference is resolved.
+ * @param output The output attributes of this CTE reference, which can be
different from
+ * the output of its corresponding CTE definition after
attribute de-duplication.
+ * @param statsOpt The optional statistics inferred from the corresponding
CTE definition.
+ */
+case class CTERelationRef(
+ cteId: Long,
Review comment:
nit: 4 spaces indentation
--
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]