Skip to content

Snowflake: parse EXCLUDE column list as ObjectName to support qualified names#2244

Merged
yoavcloud merged 3 commits intoapache:mainfrom
yoabot-droid:fix-exclude-qualified-names
Feb 27, 2026
Merged

Snowflake: parse EXCLUDE column list as ObjectName to support qualified names#2244
yoavcloud merged 3 commits intoapache:mainfrom
yoabot-droid:fix-exclude-qualified-names

Conversation

@yoabot-droid
Copy link
Contributor

Problem

When a user writes f.* EXCLUDE (f.account_canonical_id, f.amount), the parser was calling parse_identifier() for each entry in the EXCLUDE list. This only consumed the table qualifier (f), then hit the . and produced a confusing error:

Expected: "," or ")", found "."

Fix

Change ExcludeSelectItem::Single and ExcludeSelectItem::Multiple to hold ObjectName instead of Ident, and update parse_optional_select_item_exclude to call parse_object_name(false) instead of parse_identifier().

This correctly handles both plain identifiers and qualified names like f.account_canonical_id.

Changes

  • src/ast/query.rsExcludeSelectItem variants now hold ObjectName
  • src/ast/spans.rs — span impl updated to use ObjectName::span()
  • src/parser/mod.rs — parser calls parse_object_name(false)
  • Tests updated in sqlparser_common.rs, sqlparser_snowflake.rs, sqlparser_duckdb.rs

Repro

SELECT f.* EXCLUDE (f.account_canonical_id, f.amount) FROM t AS f

Now parses successfully.

@yoavcloud yoavcloud changed the title fix: parse EXCLUDE column list as ObjectName to support qualified names Snowflake: parse EXCLUDE column list as ObjectName to support qualified names Feb 27, 2026
When a user writes `f.* EXCLUDE (f.col)` instead of `f.* EXCLUDE (col)`,
the parser previously consumed only the table qualifier (e.g. `f`) as the
identifier and then hit the `.` unexpectedly, producing a confusing error
like "Expected: `,` or `)`, found `.`".

This commit detects the qualified-name pattern in
`parse_optional_select_item_exclude` and returns an actionable error:

    EXCLUDE does not support qualified column names,
    use a plain identifier instead (e.g. EXCLUDE (account_canonical_id))

Applies to both the single-column (`EXCLUDE col`) and multi-column
(`EXCLUDE (col1, col2)`) forms.

Fixes repro: `SELECT f.* EXCLUDE (f.account_canonical_id, f.amount) FROM t AS f`
@yoavcloud yoavcloud force-pushed the fix-exclude-qualified-names branch from ed32bf3 to 2b5e911 Compare February 27, 2026 12:39
@yoavcloud yoavcloud enabled auto-merge February 27, 2026 12:39
@yoavcloud yoavcloud disabled auto-merge February 27, 2026 12:40
@yoavcloud yoavcloud added this pull request to the merge queue Feb 27, 2026
Merged via the queue into apache:main with commit 49bdb5c Feb 27, 2026
10 checks passed
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.

2 participants