Skip to content

Snowflake: support wildcard with EXCLUDE in function arguments#2231

Merged
yoavcloud merged 5 commits intoapache:mainfrom
yoabot-droid:snowflake-hash-wildcard-exclude
Feb 26, 2026
Merged

Snowflake: support wildcard with EXCLUDE in function arguments#2231
yoavcloud merged 5 commits intoapache:mainfrom
yoabot-droid:snowflake-hash-wildcard-exclude

Conversation

@yoabot-droid
Copy link
Contributor

Summary

Adds support for Snowflake's HASH(* EXCLUDE(col, ...)) syntax — a wildcard with column exclusions used as a function argument.

Motivation

The following Snowflake SQL pattern was not parseable:

SELECT * FROM (
    SELECT *, HASH(*) HASH
    FROM (
        SELECT created_at::TIMESTAMP_NTZ AS created_at,
               updated_at::TIMESTAMP_NTZ AS updated_at,
               * EXCLUDE(load_date, created_at, updated_at)
        FROM mydb.public.events
    )
) S
FULL JOIN (
    SELECT *, HASH(* EXCLUDE(load_date)) HASH
    FROM mydb.archive.events_20260101
) T USING(HASH)
WHERE T.HASH IS NULL;

Changes

  • src/ast/mod.rs: Added FunctionArgExpr::WildcardWithOptions(WildcardAdditionalOptions) variant to represent * EXCLUDE(...) as a function argument expression.
  • src/ast/spans.rs: Added span handling for the new variant (returns empty span, same as plain Wildcard).
  • src/parser/mod.rs: In parse_function_args, after parsing a wildcard expression, if the dialect supports * EXCLUDE (e.g. Snowflake), attempt to parse wildcard additional options. If any options are present, wrap in WildcardWithOptions.
  • tests/sqlparser_common.rs: New test_wildcard_func_arg test covering HASH(* EXCLUDE(col)) for dialects that support wildcard EXCLUDE.

Notes

  • HASH(*) already worked before this change; only HASH(* EXCLUDE(...)) was broken.
  • The canonical form normalizes EXCLUDE(cols)EXCLUDE (cols) (space before parenthesis), matching the existing ExcludeSelectItem::Multiple display format.
  • Verified against Snowflake HASH docsEXCLUDE and ILIKE qualifiers inside HASH(*) are officially documented.
  • All existing tests pass.

@yoavcloud yoavcloud added this pull request to the merge queue Feb 26, 2026
Merged via the queue into apache:main with commit e87241a Feb 26, 2026
10 checks passed
LucaCappelletti94 pushed a commit to LucaCappelletti94/sqlparser-rs that referenced this pull request Feb 27, 2026
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