cloud-fan commented on code in PR #53526:
URL: https://github.com/apache/spark/pull/53526#discussion_r2638809045


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/normalizer/NormalizeCTEIds.scala:
##########
@@ -20,15 +20,15 @@ package org.apache.spark.sql.catalyst.normalizer
 import org.apache.spark.sql.catalyst.plans.logical.{CacheTableAsSelect, 
CTERelationRef, LogicalPlan, UnionLoop, UnionLoopRef, WithCTE}
 import org.apache.spark.sql.catalyst.rules.Rule
 
-object NormalizeCTEIds extends Rule[LogicalPlan]{
+object NormalizeCTEIds extends Rule[LogicalPlan] {
   override def apply(plan: LogicalPlan): LogicalPlan = {
-    val curId = new java.util.concurrent.atomic.AtomicLong()

Review Comment:
   This means we should handle the case when CTE def IDs can be duplicated. In 
such cases, we should not generate new IDs blindly.
   
   ```
   val defIdToNewId = withCTE.cteDefs.map(_.id).map((_, 
curId.getAndIncrement())).toMap
   ```
   
   We need to fix this line. The id map should be per `apply` invocation, not 
per `WithCTE`.



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