Skip to content

Commit bf765cd

Browse files
committed
Rename supports_snowflake_pipe_operator to supports_long_arrow_pipe_operator
1 parent aca1bb9 commit bf765cd

6 files changed

Lines changed: 16 additions & 13 deletions

File tree

src/dialect/generic.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,8 @@ impl Dialect for GenericDialect {
320320
fn supports_aliased_function_args(&self) -> bool {
321321
true
322322
}
323+
324+
fn supports_long_arrow_pipe_operator(&self) -> bool {
325+
true
326+
}
323327
}

src/dialect/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -726,11 +726,11 @@ pub trait Dialect: Debug + Any {
726726
false
727727
}
728728

729-
/// Does the dialect support the Snowflake `->>` flow/pipe operator for chaining
730-
/// SQL statements? e.g. `SELECT * FROM t ->> SELECT * FROM $1`
729+
/// Does the dialect support the `->>` flow/pipe operator for chaining SQL statements?
730+
/// e.g. `SELECT * FROM t ->> SELECT * FROM $1`
731731
///
732732
/// See <https://docs.snowflake.com/en/sql-reference/operators-flow>
733-
fn supports_snowflake_pipe_operator(&self) -> bool {
733+
fn supports_long_arrow_pipe_operator(&self) -> bool {
734734
false
735735
}
736736

src/dialect/snowflake.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ impl Dialect for SnowflakeDialect {
694694
true
695695
}
696696

697-
fn supports_snowflake_pipe_operator(&self) -> bool {
697+
fn supports_long_arrow_pipe_operator(&self) -> bool {
698698
true
699699
}
700700

src/parser/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ impl<'a> Parser<'a> {
629629

630630
// Handle Snowflake pipe operator: chain multiple statements with ->>
631631
// See <https://docs.snowflake.com/en/sql-reference/operators-flow>
632-
if self.dialect.supports_snowflake_pipe_operator()
632+
if self.dialect.supports_long_arrow_pipe_operator()
633633
&& self.peek_token_ref().token == Token::LongArrow
634634
{
635635
let mut statements = vec![stmt];
@@ -13753,7 +13753,7 @@ impl<'a> Parser<'a> {
1375313753
Token::EOF | Token::Eq | Token::SemiColon | Token::VerticalBarRightAngleBracket => {
1375413754
break
1375513755
}
13756-
Token::LongArrow if self.dialect.supports_snowflake_pipe_operator() => break,
13756+
Token::LongArrow if self.dialect.supports_long_arrow_pipe_operator() => break,
1375713757
_ => {}
1375813758
}
1375913759
self.advance_token();
@@ -16738,7 +16738,7 @@ impl<'a> Parser<'a> {
1673816738
} else {
1673916739
// Handle Snowflake pipe result references ($1, $2, ...) in FROM clause.
1674016740
// See <https://docs.snowflake.com/en/sql-reference/operators-flow>
16741-
if self.dialect.supports_snowflake_pipe_operator() {
16741+
if self.dialect.supports_long_arrow_pipe_operator() {
1674216742
if let Token::Placeholder(ref s) = self.peek_token_ref().token.clone() {
1674316743
if let Some(index_str) = s.strip_prefix('$') {
1674416744
if let Ok(index @ 1..) = index_str.parse::<u64>() {

tests/sqlparser_common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ fn parse_json_ops_without_colon() {
17231723
(
17241724
"->>",
17251725
LongArrow,
1726-
all_dialects_except(|d| d.supports_snowflake_pipe_operator()),
1726+
all_dialects_except(|d| d.supports_long_arrow_pipe_operator()),
17271727
),
17281728
("#>", HashArrow, pg_and_generic()),
17291729
("#>>", HashLongArrow, pg_and_generic()),

tests/sqlparser_snowflake.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4953,13 +4953,12 @@ fn test_snowflake_pipe_operator() {
49534953
))
49544954
);
49554955

4956-
// In GenericDialect, ->> remains a binary (JSON extract) operator, not a pipe
4956+
// GenericDialect also supports pipe syntax (it is permissive by design)
49574957
use sqlparser::dialect::GenericDialect;
49584958
use sqlparser::parser::Parser;
4959-
let stmts = Parser::parse_sql(&GenericDialect {}, "SELECT payload ->> 'name'").unwrap();
4960-
assert_eq!(stmts.len(), 1);
4961-
// In GenericDialect, SELECT 1 ->> SELECT 2 is a parse error (SELECT 2 is not an expression)
4962-
assert!(Parser::parse_sql(&GenericDialect {}, "SELECT 1 ->> SELECT 2").is_err());
4959+
Parser::parse_sql(&GenericDialect {}, "SELECT * FROM t ->> SELECT * FROM $1").unwrap();
4960+
// JSON ->> binary operator still works inside expressions
4961+
Parser::parse_sql(&GenericDialect {}, "SELECT payload ->> 'name'").unwrap();
49634962
}
49644963

49654964
#[test]

0 commit comments

Comments
 (0)