TJX2014 commented on a change in pull request #29156:
URL: https://github.com/apache/spark/pull/29156#discussion_r458842763



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveHints.scala
##########
@@ -165,6 +165,24 @@ object ResolveHints {
           hintErrorHandler.hintRelationsNotFound(h.name, h.parameters, 
unmatchedIdents)
           applied
         }
+      case With(child, relations) => resolveCTEHint(child,
+        relations.foldLeft(Seq.empty[(String, LogicalPlan)]) {
+        case (resolved, (name, relation)) =>
+          resolved :+ name -> apply(resolveCTEHint(relation, resolved))
+      })
+    }
+
+    def resolveCTEHint(plan: LogicalPlan, cteRelations: Seq[(String, 
LogicalPlan)]): LogicalPlan = {
+      plan resolveOperatorsDown {
+        case u: UnresolvedRelation =>
+          cteRelations.find(x => resolver(x._1, 
u.tableName)).map(_._2).getOrElse(u)

Review comment:
       This branch will occur `stackoverflow` when cte table name is same as 
table in cte as follows:
   sql("create temporary view t as select 1 as id")      
   sql("with **t** as (select /*+ BROADCAST(id) */ id from **t**) select id 
from t")
   @cloud-fan  Could you please help me find a way to pass this ? 




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

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