Repository navigation
DuckDB: support * RENAME, unparenthesized star modifiers and a trailing comma - #2801
Merged
manticore-projects merged 3 commits intoOct 13, 2026
Merged
Conversation
guizmaii
marked this pull request as ready for review
October 13, 2026 09:19
27 tasks
guizmaii
force-pushed
the
duckdb-star-modifiers
branch
4 times, most recently
from
October 13, 2026 21:59
12ff9c7 to
a80100c
Compare
Contributor
|
sorry, conflicts from overlapping PRs. Please resolve. |
…ng comma - `* RENAME (i AS x, j AS y)` and `* RENAME i AS x` are the new RENAME `ColumnsTransformer`. - After `*`, `EXCLUDE i`, `REPLACE i + 1 AS i` and `RENAME i AS x` may name a single column or item without parentheses, and print back that way. Unparenthesized REPLACE and RENAME require the `AS name`. - A select list may end with a comma before a clause such as FROM, WHERE or `ORDER BY`, or before `)`. Keywords that may name a column, as in `SELECT a, limit FROM t`, still do. The comma is not printed.
- Unparenthesized REPLACE needs an AS at the top level of its item, and RENAME needs `column AS name` for each item, so `* rename` and `* replace` stay aliases of the star. - `REPLACE (a + 1) AS a` is a single item, as in DuckDB, not a list without an alias. - A comma before `limit(` or `offset(` starts a select item again, and `group by` / `order by` right before FROM or the end are a column and its alias. - A transformer with more than one item or column prints parentheses.
guizmaii
force-pushed
the
duckdb-star-modifiers
branch
from
October 13, 2026 22:25
a80100c to
8353381
Compare
Contributor
|
Thank you! |
Contributor
Author
|
Rebased on master, conflicts resolved. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For DuckDB's star expression modifiers (docs) and trailing commas in the select list (docs).
* RENAME (i AS x, j AS y),* RENAME i AS xColumnsTransformerof the new typeRENAME* EXCLUDE i,* EXCLUDE t.iEXCLUDEwith one column, printed without parentheses* REPLACE i + 1 AS iREPLACEwith one item, printed without parenthesesSELECT a, b, FROM t,SELECT 1, LIMIT 1,(SELECT 1,)ColumnsTransformergainsgetRenameItems()andisParenthesized(). The unparenthesized forms are only recognised after*/t.*, as in DuckDB.REPLACE itemneeds anASat its top level andRENAMEneedscolumn AS namefor every column, so* rename/* replacestay aliases of the star and ClickHouse'sREPLACE STRICTchecks are unchanged.* REPLACE (a + 1) AS ais now DuckDB's single item(a + 1) AS a; it used to be an unaliasedREPLACE(a + 1)with the star aliaseda, which no dialect accepts.), FROM, WHERE, HAVING, WINDOW, INTO, a set operator,GROUP BY/ORDER BYwith an expression, andLIMIT/OFFSETfollowed by a number or?. Columns and functions named after keywords keep parsing:SELECT a, limit FROM t,SELECT a, limit(1) FROM t,SELECT a, group by FROM t. A comma at the end of the input stays an error, andSELECT 1, LIMIT ALLis still a column. It applies wherever a select item list is parsed (RETURNING, PIVOT ... IN, DISTINCT ON, ...).checkGrammarAmbiguity: no conflicts../gradlew check: 10,118 tests, 0 failures.test/sql, 70,729 statements): 146 more parse, none less.