MaxGekk commented on code in PR #49442:
URL: https://github.com/apache/spark/pull/49442#discussion_r1918761309


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/parameters.scala:
##########
@@ -176,15 +162,18 @@ object BindParameters extends ParameterizedQueryProcessor 
with QueryErrorsBase {
     }
   }
 
-  private def bind(p: LogicalPlan)(f: PartialFunction[Expression, 
Expression]): LogicalPlan = {
-    p.resolveExpressionsWithPruning(_.containsPattern(PARAMETER)) (f orElse {
-      case sub: SubqueryExpression => sub.withNewPlan(bind(sub.plan)(f))
-    })
+  private def bind(p0: LogicalPlan)(f: PartialFunction[Expression, 
Expression]): LogicalPlan = {
+    var stop = false
+    p0.resolveOperatorsDownWithPruning(_.containsPattern(PARAMETER) && !stop) {
+      case p1 =>
+        stop = p1.isInstanceOf[ParameterizedQuery]

Review Comment:
   @cloud-fan How about this API:
   ```scala
       p0.resolveOperatorsDownUntil(
         p1 => !p1.containsPattern(PARAMETER) || 
p1.isInstanceOf[ParameterizedQuery]) {
         f orElse {
           case sub: SubqueryExpression => sub.withNewPlan(bind(sub.plan)(f))
         }
       }
   ```
   it executes body until `stopCondition: T => Boolean` returns `true` 
including the last operator. So, it is like `repeat .. until` in Pascal or `do 
.. while` in C/C++. In our case, we need to substitute parameters in variables 
of a `ParameterizedQuery` on which we have to stop. 



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to