Skip to content

Comments

Snowflake: support wildcard with EXCLUDE in function arguments#2231

Open
yoabot-droid wants to merge 5 commits intoapache:mainfrom
yoabot-droid:snowflake-hash-wildcard-exclude
Open

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

Conversation

@yoabot-droid
Copy link

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.

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