andrej-db commented on code in PR #45293:
URL: https://github.com/apache/spark/pull/45293#discussion_r1507412827


##########
sql/core/src/test/scala/org/apache/spark/sql/execution/QueryExecutionSuite.scala:
##########
@@ -336,6 +336,18 @@ class QueryExecutionSuite extends SharedSparkSession {
     }
   }
 
+  test("SPARK-47033: EXECUTE IMMEDIATE USING does not recognize session 
variable names") {
+    spark.sql("DECLARE parm = 'Hello';")
+
+    val originalQuery = spark.sql("EXECUTE IMMEDIATE 'SELECT :parm' USING parm 
AS parm;")
+    val newQuery = spark.sql("EXECUTE IMMEDIATE 'SELECT :parm' USING parm;")

Review Comment:
   ```
   val aliases = expressions.collect {
       case e: Alias => e
       case u: UnresolvedAttribute => Alias(u, u.nameParts.last)()
   }
   ```
   
   Now this works:
   `EXECUTE IMMEDIATE 'SELECT :parm' USING system.session.parm;`
   
   But I am not sure if this is intended. If you use anything else with more 
name parts it will autocreate an alias with the final part.



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