-
Notifications
You must be signed in to change notification settings - Fork 28.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-50785][SQL] Refactor FOR statement to utilize local variables …
…properly ### What changes were proposed in this pull request? This PR refactors FOR statement to use local variables instead of session variables to represent columns. Previously, FOR simulated local variables by artificially creating and dropping session variables, which caused a number of issues. In this PR, we create an internal `CompoundBodyExec` to represent the "scope" of the FOR statement. Within this body we declare local variables, which are automatically cleaned up when we exit the scope. We set the label of this body to the FOR variable name, if present, which enables easy access to the columns by qualifying with the FOR variable name. ### Why are the changes needed? Previous version had a number of issues, e.g. nested for loops with same column names would fail. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? `SqlScriptingInterpreterSuite` and `SqlScriptingExecutionNodeSuite` were updated. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #50026 from dusantism-db/scripting-for-improvements-v2. Authored-by: Dušan Tišma <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
- Loading branch information
1 parent
7feb911
commit 0184c5b
Showing
4 changed files
with
486 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.