cloud-fan commented on a change in pull request #34929:
URL: https://github.com/apache/spark/pull/34929#discussion_r779643115
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/InlineCTE.scala
##########
@@ -93,25 +101,24 @@ object InlineCTE extends Rule[LogicalPlan] {
private def inlineCTE(
plan: LogicalPlan,
cteMap: mutable.HashMap[Long, (CTERelationDef, Int)],
- forceInline: Boolean): LogicalPlan = {
- val (stripped, notInlined) = plan match {
+ notInlined: mutable.ArrayBuffer[CTERelationDef]): LogicalPlan = {
+ plan match {
case WithCTE(child, cteDefs) =>
- val notInlined = mutable.ArrayBuffer.empty[CTERelationDef]
cteDefs.foreach { cteDef =>
val (cte, refCount) = cteMap(cteDef.id)
if (refCount > 0) {
- val inlined = cte.copy(child = inlineCTE(cte.child, cteMap,
forceInline))
+ val inlined = cte.copy(child = inlineCTE(cte.child, cteMap,
notInlined))
cteMap.update(cteDef.id, (inlined, refCount))
- if (!forceInline && !shouldInline(inlined, refCount)) {
+ if (!shouldInline(inlined, refCount)) {
notInlined.append(inlined)
}
}
}
- (inlineCTE(child, cteMap, forceInline), notInlined.toSeq)
+ inlineCTE(child, cteMap, notInlined)
case ref: CTERelationRef =>
val (cteDef, refCount) = cteMap(ref.cteId)
- val newRef = if (forceInline || shouldInline(cteDef, refCount)) {
+ if (shouldInline(cteDef, refCount)) {
if (ref.outputSet == cteDef.outputSet) {
Review comment:
why do we compare output set, not output? is it possible that the ref
and def have different output column order?
--
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]