Skip to content

fix: parse EXCLUDE column list as ObjectName to support qualified names#6

Open
yoabot-droid wants to merge 11 commits intomainfrom
fix-exclude-qualified-names
Open

fix: parse EXCLUDE column list as ObjectName to support qualified names#6
yoabot-droid wants to merge 11 commits intomainfrom
fix-exclude-qualified-names

Conversation

@yoabot-droid
Copy link
Owner

@yoabot-droid yoabot-droid commented Feb 26, 2026

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.

@yoabot-droid yoabot-droid force-pushed the fix-exclude-qualified-names branch from 85a49a6 to 2290573 Compare February 26, 2026 11:03
@yoabot-droid yoabot-droid changed the title fix: clear error for qualified column names in EXCLUDE clause fix: parse EXCLUDE column list as ObjectName to support qualified names Feb 26, 2026
@yoabot-droid yoabot-droid force-pushed the fix-exclude-qualified-names branch from 2290573 to ed32bf3 Compare February 26, 2026 11:08
yoabot-droid and others added 6 commits February 26, 2026 11:11
Co-authored-by: Yoav Cohen <59807311+yoavcloud@users.noreply.github.com>
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
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.

4 participants