shivadarshan-devadiga commented on code in PR #60756:
URL: https://github.com/apache/spark/pull/60756#discussion_r4646756222


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/cteOperators.scala:
##########
@@ -51,9 +51,9 @@ case class UnionLoop(
     copy(anchor = newChildren(0), recursion = newChildren(1))
 
   override protected def computeOutput(): Seq[Attribute] =
-    Union.mergeChildOutputs(children.map(_.output)).zip(outputAttrIds).map { 
case (x, id) =>
-      x.withExprId(id)
-    }
+    // ApplyCharTypePadding does not pad the anchor and recursion to the same 
CHAR lengths.
+    Union.mergeChildOutputs(children.map(_.output), widenCharLengths = false)

Review Comment:
   Fixed. A set operation that reads the recursive reference of a recursive CTE 
it is not part of (`CTERelationRef` with `recursive`, or `UnionLoopRef`) now 
keeps its CHAR lengths, like the `UnionLoop` (`Union.readsRecursiveReference`). 
This applies to its output in both analyzers, including 
`SetOperationLikeResolver`, and to `ApplyCharTypePadding`. A set operation over 
a whole recursive CTE is still widened. Your query, with the t5 branch filtered 
out so the recursion ends, is in the set-operations test and returns n = 0, 1, 
2.



-- 
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