BenSatori commented on code in PR #2438:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2438#discussion_r3802621667


##########
tests/sqlparser_snowflake.rs:
##########
@@ -4912,3 +4912,61 @@ fn test_select_dollar_column_from_stage() {
     // With table function args, without alias
     snowflake().verified_stmt("SELECT $1, $2 FROM @mystage1(file_format => 
'myformat')");
 }
+
+#[test]
+fn test_snowflake_pipe_operator() {
+    // Basic pipe: two SELECT statements chained
+    snowflake().verified_stmt("SELECT * FROM tablename ->> SELECT * FROM $1");
+
+    // Three statements chained
+    snowflake().verified_stmt(
+        "SELECT * FROM dept WHERE dname = 'SALES' ->> SELECT * FROM emp WHERE 
deptno IN (SELECT deptno FROM $1) ->> SELECT ename, sal FROM $1 ORDER BY 2 
DESC",
+    );
+
+    // Reference to a non-adjacent prior result using $2
+    snowflake().verified_stmt("SELECT a FROM t ->> SELECT b FROM t2 ->> SELECT 
$1 FROM $2");
+
+    // Non-SELECT statements in the chain (CREATE/INSERT)
+    snowflake()
+        .verified_stmt("CREATE TABLE t (id INT) ->> INSERT INTO t VALUES (1) 
->> SELECT * FROM $1");
+
+    // Pipe operator is not parsed in non-Snowflake dialects
+    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();

Review Comment:
   Added that to GenericDialect, and also renamed it so it doesn't look awkward 
(in case other DBs adds support for this as well).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to