Snowflake: Add support for ->> (pipe) operator for chaining SQL stmts - #2438
Open
BenSatori wants to merge 4 commits into
Open
Snowflake: Add support for ->> (pipe) operator for chaining SQL stmts#2438BenSatori wants to merge 4 commits into
BenSatori wants to merge 4 commits into
Conversation
LucaCappelletti94
suggested changes
Aug 18, 2026
| false | ||
| } | ||
|
|
||
| /// Does the dialect support the Snowflake `-->` flow/pipe operator for chaining |
Contributor
There was a problem hiding this comment.
This looks like a typo
| } | ||
|
|
||
| #[test] | ||
| fn test_snowflake_pipe_operator() { |
Contributor
There was a problem hiding this comment.
Several cases that I am not sure are currently corrected supported, such as the following ones, should be added to the tests. These are ones from the Snowflake docs:
// Exact documented SHOW shape.
verified_stmt(
r#"SHOW WAREHOUSES
->> SELECT "name", "state", "type", "size" FROM $1"#,
);
// A Snowflake dialect override that currently scans until EOF/semicolon.
verified_stmt("CREATE DATABASE d ->> SELECT 1");
// Existing happy path.
verified_stmt(
"CREATE TABLE t (id INT)
->> INSERT INTO t VALUES (1)
->> SELECT * FROM $1"
);
// Error paths.
assert_parse_error("SELECT 1 ->>");
assert_parse_error("SELECT * FROM $0");
// GenericDialect ambiguity.
verified_generic_expr("SELECT payload ->> 'name'");
verified_generic_pipe("SELECT 1 ->> SELECT 2");
| if self.dialect.supports_snowflake_pipe_operator() { | ||
| if let Token::Placeholder(ref s) = self.peek_token_ref().token.clone() { | ||
| if let Some(index_str) = s.strip_prefix('$') { | ||
| if let Ok(index) = index_str.parse::<u64>() { |
Contributor
There was a problem hiding this comment.
Here you are currently accepting $0, maybe replace with:
if let Ok(index @ 1..) = index_str.parse::<u64>() {
| use sqlparser::dialect::GenericDialect; | ||
| use sqlparser::parser::Parser; | ||
| // In a generic dialect, ->> is a binary operator, not a pipe | ||
| let stmts = Parser::parse_sql(&GenericDialect {}, "SELECT 1").unwrap(); |
Contributor
There was a problem hiding this comment.
What is this even meant to test? Also, GenericDialect would generally be a dialect that supports all syntaxes, and should therefore likely also support this one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The ->> (flow/pipe) operator chains multiple SQL statements in Snowflake.
Before: Parser rejected pipe chains like
SELECT * FROM t1 ->> SELECT * FROM $1After: Parser correctly handles:
Example:
Changes:
Snowflake docs:
https://docs.snowflake.com/en/sql-reference/operators-flow#pipe