You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "funcpp (via GitHub)" <gi...@apache.org> on 2026/03/31 04:04:31 UTC

[PR] Support multi-column aliases in SELECT items [datafusion-sqlparser-rs]

funcpp opened a new pull request, #2289:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2289

   ## Summary
   
   Add support for parenthesized multi-column aliases in SELECT items, as defined in the [Spark SQL grammar](https://github.com/apache/spark/blob/master/sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4):
   
   ```
   namedExpression
       : expression (AS? (name=errorCapturingIdentifier | identifierList))?
       ;
   
   identifierList
       : LEFT_PAREN identifierSeq RIGHT_PAREN
       ;
   ```
   
   This enables syntax like:
   ```sql
   SELECT stack(2, 'a', 'b', 'c', 'd') AS (col1, col2)
   ```
   
   ### Changes
   - Add `SelectItem::ExprWithAliases` variant for multi-column aliases
   - Add `Dialect::supports_select_item_multi_column_alias()`, enabled for Databricks and Generic dialects
   - Parse `AS (ident, ident, ...)` when the dialect supports it
   
   ### Context
   While not documented in the [Databricks SQL reference](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-qry-select.html), this syntax is part of the Spark SQL grammar that Databricks implements. Verified to execute successfully on Databricks Runtime:
   ```sql
   SELECT stack(2, 'a', 'b', 'c', 'd') AS (col1, col2)
   -- Returns:
   -- col1  col2
   -- a     b
   -- c     d
   ```
   
   ## Test plan
   - [x] Round-trip test: `SELECT stack(...) AS (col1, col2)` with and without FROM
   - [x] Negative test: non-supporting dialects reject the syntax
   - [x] Existing tests unaffected
   - [x] `cargo fmt`, `cargo clippy`, full test suite pass


-- 
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: github-unsubscribe@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Support multi-column aliases in SELECT items [datafusion-sqlparser-rs]

Posted by "funcpp (via GitHub)" <gi...@apache.org>.
funcpp commented on PR #2289:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2289#issuecomment-4215117400

   @yoavcloud Rebased, Could you check it?


-- 
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: github-unsubscribe@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Support multi-column aliases in SELECT items [datafusion-sqlparser-rs]

Posted by "yoavcloud (via GitHub)" <gi...@apache.org>.
yoavcloud commented on code in PR #2289:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2289#discussion_r3056625277


##########
tests/sqlparser_databricks.rs:
##########
@@ -644,3 +644,17 @@ fn parse_databricks_json_accessor() {
         "SELECT raw:store.bicycle.price::DOUBLE FROM store_data",
     );
 }
+
+#[test]

Review Comment:
   Can this test move to common?



-- 
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: github-unsubscribe@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Support multi-column aliases in SELECT items [datafusion-sqlparser-rs]

Posted by "funcpp (via GitHub)" <gi...@apache.org>.
funcpp commented on code in PR #2289:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2289#discussion_r3056872913


##########
tests/sqlparser_databricks.rs:
##########
@@ -644,3 +644,17 @@ fn parse_databricks_json_accessor() {
         "SELECT raw:store.bicycle.price::DOUBLE FROM store_data",
     );
 }
+
+#[test]

Review Comment:
   moved it 👍🏻 



-- 
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: github-unsubscribe@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Support multi-column aliases in SELECT items [datafusion-sqlparser-rs]

Posted by "yoavcloud (via GitHub)" <gi...@apache.org>.
yoavcloud merged PR #2289:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2289


-- 
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: github-unsubscribe@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org