Skip to content
This repository was archived by the owner on Oct 1, 2026. It is now read-only.

SYN-1945 Support Snowflake TRIM. - #2

Merged
zdenal merged 1 commit into
mainfrom
zdenko/snowflake-parse-trim-with-second-param-2
Sep 22, 2023
Merged

zdenal merged 1 commit into
mainfrom
zdenko/snowflake-parse-trim-with-second-param-2

Conversation

@zdenal

@zdenal zdenal commented Sep 22, 2023 •

Copy link
Copy Markdown

Why

We are getting errors with parsing snowflake TRIM expression including removing characters separated by comma.

https://docs.snowflake.com/en/sql-reference/functions/trim

Example of real failing sql

WITH sub_coupons AS (
    SELECT
        customer_id,
        subscription_id,
        TRIM(coupons.value:coupon_id, '"') AS coupon_id
    FROM model_staging.subscriptions,
    TABLE(FLATTEN(PARSE_JSON(coupons))) AS coupons
),

Comment thread src/parser.rs
trim_what: Some(trim_what),
trim_characters: None,
})
} else if self.consume_token(&Token::Comma) && dialect_of!(self is SnowflakeDialect) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no FROM and Snowflake and next is Comma (by doc Snowflake doesn't support FROM syntax) -> parse characters

Comment thread tests/sqlparser_common.rs
Box::new(PostgreSqlDialect {}),
Box::new(MsSqlDialect {}),
Box::new(AnsiDialect {}),
//Box::new(SnowflakeDialect {}),

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure it is still failing on others than snowflake.

@@ -0,0 +1,36 @@
name: Test Suite

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added simple test workflow to see on PRs results of tests.

@zdenal
zdenal marked this pull request as ready for review September 22, 2023 10:52
@zdenal zdenal self-assigned this Sep 22, 2023
@zdenal
zdenal requested a review from lustefaniak September 22, 2023 10:52
Comment thread src/ast/mod.rs
}
if let Some(characters) = trim_characters {
write!(f, ", {}", display_comma_separated(characters))?;
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print trim characters after expression if there are

@zdenal
zdenal force-pushed the zdenko/snowflake-parse-trim-with-second-param-2 branch from c01f05c to 0398ed5 Compare September 22, 2023 11:25
@zdenal
zdenal merged commit 9bce54f into main Sep 22, 2023
@zdenal zdenal changed the title Support Snowflake TRIM. SYN-1945 Support Snowflake TRIM. Sep 22, 2023
@lustefaniak
lustefaniak deleted the zdenko/snowflake-parse-trim-with-second-param-2 branch October 27, 2023 16:59
lustefaniak added a commit that referenced this pull request Feb 17, 2026
Parse DuckDB's #1, #2 positional column references as Value::Placeholder.
DuckDB tokenizes # as Token::Sharp followed by a number.
lustefaniak added a commit that referenced this pull request Feb 17, 2026
Parse DuckDB's #1, #2 positional column references as Value::Placeholder.
DuckDB tokenizes # as Token::Sharp followed by a number.
lustefaniak added a commit that referenced this pull request Feb 17, 2026
Parse DuckDB's #1, #2 positional column references as Value::Placeholder.
DuckDB tokenizes # as Token::Sharp followed by a number.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants