vladimirg-db opened a new pull request, #46209:
URL: https://github.com/apache/spark/pull/46209

   ### What changes were proposed in this pull request?
   Mark `DescribeQueryCommand` and `ExplainCommand` as `SupervisingCommand` 
(they don't expose their wrapped nodes, but supervise them internally). 
Introduce a new Analyzer rule `MoveParameterizedQueriesDown `, which moves 
`ParameterizedQuery` inside `SupervisingCommand` for parameters to be resolved 
correctly.
   
   
   ### Why are the changes needed?
   Parameterized `EXPLAIN` and `DESCRIBE` queries:
   - `spark.sql("describe select ?", Array(1)).show();`
   - `spark.sql("explain select ?", Array(1)).show();`
   fail with
   `org.apache.spark.sql.catalyst.ExtendedAnalysisException: 
[UNBOUND_SQL_PARAMETER] Found the unbound parameter: _16. Please, fix `args` 
and provide a mapping of the parameter to either a SQL literal or collection 
constructor functions such as `map()`, `array()`, `struct()`. SQLSTATE: 42P02; 
line 1 pos 16; 'Project [unresolvedalias(posparameter(16))] +- OneRowRelation`
   
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, parameterized `EXPLAIN` and `DESCRIBE` should start working for users
   
   
   ### How was this patch tested?
   - Run `sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala`
   - Run `sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala`
   - New tests for `SQLQuerySuite`
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   No
   


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