srielau commented on PR #49442:
URL: https://github.com/apache/spark/pull/49442#issuecomment-2585359079
Let me add some more color:
"EXECUTE IMMEDIATE 'SELECT :var1, :var2' USING :var2 AS var1, :var1 AS
var2", map("var1" -> 5, "var2" -> 6)
The EXECUTE IMMEDIATE binds in map("var1" -> 5, "var2" -> 6)
But the SELECT binds in map("var1" -> 6, "var2" -> 5)
The nested query can only communicate through the USING clause.
Let's add SQL Scripting
BEGIN
DECLARE var1 INT;
EXECUTE IMMEDIATE 'SELECT var1';
END;
This is an error! The local variable var1 is NOT visible to the execute
immediate.
This works however because var1 is a session variable and the nested select
is of course in the same session.
DECLARE var1 INT;
BEGIN
EXECUTE IMMEDIATE 'SELECT var1';
END;
--
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]