Skip to content

Comments

Redshift: support wildcard select items with alias#2230

Open
yoabot-droid wants to merge 2 commits intoapache:mainfrom
yoabot-droid:fix/redshift-wildcard-alias
Open

Redshift: support wildcard select items with alias#2230
yoabot-droid wants to merge 2 commits intoapache:mainfrom
yoabot-droid:fix/redshift-wildcard-alias

Conversation

@yoabot-droid
Copy link

Problem

Redshift supports aliasing wildcard expressions in SELECT statements:

SELECT t.* AS alias FROM t

Previously the parser would fail with:

ParserError("Expected: end of statement, found: AS")

Confirmed working on a live Redshift database.

Solution

  • Added opt_alias: Option<Ident> field to WildcardAdditionalOptions
  • Added supports_select_wildcard_with_alias() method to the Dialect trait (default: false)
  • Enabled it in RedshiftSqlDialect
  • Parser now consumes AS <alias> when the dialect supports it
  • Updated Display and span tracking for the new field

Tests

Added regression tests in tests/sqlparser_common.rs using all_dialects_where(|d| d.supports_select_wildcard_with_alias()):

  • Qualified wildcard with alias: SELECT t.* AS all_cols FROM t
  • Unqualified wildcard with alias: SELECT * AS all_cols FROM t
  • Mixed multi-join query with regular column + qualified wildcard alias

…alias)

Redshift allows aliasing wildcard expressions in SELECT, e.g.:
  SELECT t.* AS alias FROM t

Previously the parser would fail with:
  ParserError("Expected: end of statement, found: AS")

Fix: add opt_alias field to WildcardAdditionalOptions and parse the
optional AS <alias> clause when the dialect supports it.

Adds supports_select_wildcard_with_alias() dialect method, enabled for
RedshiftSqlDialect.
Use all_dialects_where(|d| d.supports_select_wildcard_with_alias())
so tests apply to any dialect that enables the feature, per project
conventions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant