cloud-fan commented on a change in pull request #29156:
URL: https://github.com/apache/spark/pull/29156#discussion_r458941369



##########
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:
       Have you looked at https://github.com/apache/spark/pull/29062 ? Seems 
easier to just run CTE substitution in the very beginning.




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