Skip to content

Comments

fix(redshift): support wildcard select items with alias (e.g. t.* AS alias)#2229

Closed
yoabot-droid wants to merge 1 commit intoapache:mainfrom
yoabot-droid:fix/redshift-wildcard-alias
Closed

fix(redshift): support wildcard select items with alias (e.g. t.* AS alias)#2229
yoabot-droid wants to merge 1 commit 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")

This was 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 the method in RedshiftSqlDialect
  • In parse_wildcard_additional_options, parse an optional AS <alias> when the dialect supports it
  • Updated Display and span tracking for the new field

Tests

Added regression tests in tests/sqlparser_redshift.rs:

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