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

   ### What changes were proposed in this pull request?
   
   This PR extends the `SET CATALOG` statement to accept foldable expressions.
   
   - Modified SQL grammar to accept expressions in addition to catalog 
identifiers.
   - Updated parser to handle both traditional identifiers and expressions 
(e.g., CAST, CONCAT, and etc). The expressions are validated in the analyzer to 
ensure they are foldable, non-null, and evaluate to a string type via 
IdentifierResolution.
   
   ### Why are the changes needed?
   
   This change simplifies the use of foldable expressions in the `SET CATALOG` 
statement by allowing users to run `SET CATALOG some_function()` directly, 
without the previously required `IDENTIFIER` clause.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Before this change, the `SET CATALOG` statement accepted the following 
identifiers
   
   - Simple identifier: `SET CATALOG my_catalog`
   - String literal: `SET CATALOG 'my_catalog'`
   - identifier() function: `SET CATALOG identifier('my_catalog')`
   
   And after this change, the `SET CATALOG` statement additionally supports
   - `CAST`, `CONCAT`, or other foldable expressions: `SET CATALOG 
CAST('my_catalog' AS STRING)`.
   
   ### How was this patch tested?
   
   Unit tests in DataSourceV2SQLSuite:
     1. SET CATALOG with foldable expressions - Verifies support for:
       - SET CATALOG CAST("testcat" AS STRING)
       - SET CATALOG CONCAT('test', 'cat2')
     2. SET CATALOG is case-sensitive - Confirms case-sensitivity across all 
forms:
       - Simple identifiers: SET CATALOG teStCaT
       - String literals: SET CATALOG 'teStCaT'
       - IDENTIFIER function: SET CATALOG IDENTIFIER('teStCaT') 
       - Foldable expressions: SET CATALOG CONCAT('teSt', 'CaT')
     3. SET CATALOG with session temp variables - Tests variable references:
       - SET CATALOG IDENTIFIER(cat_name) (works with declared variables)
       - SET CATALOG cat_name (fails - requires IDENTIFIER wrapper)
     4. Negative tests for invalid inputs:
       - Non-foldable expressions: SET CATALOG current_user() (fails with 
NOT_CONSTANT error)
       - Null values: SET CATALOG NULL and SET CATALOG CAST(NULL AS STRING) 
(fail)
       - Non-string types: SET CATALOG 42 and SET CATALOG 3.14 (fail with 
WRONG_TYPE error)
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Claude Sonnet 4.5 - claude-sonnet-4-5-20250929)


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