andrej-db commented on code in PR #45293:
URL: https://github.com/apache/spark/pull/45293#discussion_r1508757748
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/executeImmediate.scala:
##########
@@ -122,11 +122,14 @@ class SubstituteExecuteImmediate(val catalogManager:
CatalogManager)
resolveArguments(expressions))
} else {
val aliases = expressions.collect {
- case (e: Alias) => e
+ case e: Alias => e
+ case u: UnresolvedAttribute => Alias(u, u.name)()
Review Comment:
I can do the following in
`sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/VariableReference.scala`:
```
override def toString: String = {
// REMOVE >> val qualifiedName = (catalog.name +: identifier.namespace
:+ identifier.name).map(quoteIfNeeded)
// REMOVE >>
s"$prettyName(${qualifiedName.mkString(".")}=${varDef.currentValue.sql})"
identifier.name // << ADD
}
```
This allows for
> seems we can just collect `NamedExpression`.
> ```
> val namedExpressions = expressions.collect {
> case e: NamedExpression => e
> }
> ```
>
> for the following query
>
> ```
> EXECUTE IMMEDIATE 'SELECT :parm' USING parm;
> ```
The output is as follows:
```
+-----+
|parm |
+-----+
|Hello|
+-----+
```
which is the correct output.
This is @srielau 's code which I do not know if I should edit (although
tests pass with this mod).
@srielau @cloud-fan if this should be edited let me know, if not the Alias
fix is ready to go.
--
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]