dtenedor opened a new pull request, #46451:
URL: https://github.com/apache/spark/pull/46451

   ### What changes were proposed in this pull request?
   
   This PR improves the error message when a table-valued function call has a 
TABLE argument with a PARTITION BY or ORDER BY clause with more than one 
associated expression, but forgets parentheses around them.
   
   For example:
   
   ```
   SELECT * FROM testUDTF(
     TABLE(SELECT 1 AS device_id, 2 AS data_ds)
     WITH SINGLE PARTITION
     ORDER BY device_id, data_ds)
   ```
   
   This query previously returned an obscure, unrelated error:
   
   ```
   [UNSUPPORTED_SUBQUERY_EXPRESSION_CATEGORY.UNSUPPORTED_TABLE_ARGUMENT] 
Unsupported subquery expression: Table arguments are used in a function where 
they are not supported:
   'UnresolvedTableValuedFunction [tvf], [table-argument#338 [], 
'data_ds](https://issues.apache.org/jira/browse/SPARK-48180#338%20[],%20'data_ds),
 false
      +- Project [1 AS device_id#336, 2 AS 
data_ds#337](https://issues.apache.org/jira/browse/SPARK-48180#336,%202%20AS%20data_ds#337)
         +- OneRowRelation
   ```
   
   Now it returns a reasonable error:
   
   ```
   The table function call includes a table argument with an invalid 
partitioning/ordering specification: the ORDER BY clause included multiple 
expressions without parentheses surrounding them; please add parentheses around 
these expressions and then retry the query again. (line 4, pos 2)
   
   == SQL ==
   
   SELECT * FROM testUDTF(
     TABLE(SELECT 1 AS device_id, 2 AS data_ds)
     WITH SINGLE PARTITION
   --^^^
     ORDER BY device_id, data_ds)
   ```
   
   ### Why are the changes needed?
   
   Here we improve error messages for common SQL syntax mistakes.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, see above.
   
   ### How was this patch tested?
   
   This PR adds test coverage.
   
   ### 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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to