Repository navigation
Conversation
LucaCappelletti94
left a comment
There was a problem hiding this comment.
Just a nit pick, then it should me mergiable imho
|
@iffyio do you think we can merge this? |
|
@BenSatori GitHub CI / queue is currently chocking, it'll take a while for it to clear. |
ffb2bf2 to
f8292c6
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2438 +/- ##
==========================================
+ Coverage 81.09% 81.12% +0.03%
==========================================
Files 42 42
Lines 33684 33746 +62
Branches 33684 33746 +62
==========================================
+ Hits 27316 27378 +62
+ Misses 2798 2796 -2
- Partials 3570 3572 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| if let Token::Placeholder(ref s) = self.peek_token_ref().token.clone() { | ||
| if let Some(Ok(index @ 1..)) = s.strip_prefix('$').map(str::parse::<u64>) { | ||
| self.next_token(); // consume the $n token | ||
| return Ok(TableFactor::PipeResultScan { index }); |
There was a problem hiding this comment.
Snowflake accepts an alias here: SELECT 1 AS a ->> SELECT t.a FROM $1 AS t and ... ->> SELECT t.a, u.b FROM $2 AS t CROSS JOIN $1 AS u both run on Cloud but are rejected with Expected: end of statement, found: AS. Suggest an alias: Option<TableAlias> on the variant via maybe_parse_table_alias, which also removes the need for the parenthesized-alias error above.
| break; | ||
| } | ||
| Token::LongArrow => { | ||
| // Snowflake pipe operator terminates the statement |
There was a problem hiding this comment.
The same end-of-statement loops in parse_copy_into (COPY INTO t FROM @s ->> SELECT * FROM $1), parse_alter_session (ALTER SESSION SET QUERY_TAG = 'x' ->> SELECT 1, valid on Cloud) and parse_key_value_options in src/parser/mod.rs (CREATE WAREHOUSE w ->> SELECT 1, CREATE USER u ->> SELECT 1) still reject ->>. A single end-of-statement predicate on Parser that includes ->> when the dialect supports it would cover all of them.
| true | ||
| } | ||
|
|
||
| fn supports_long_arrow_pipe_operator(&self) -> bool { |
There was a problem hiding this comment.
In Generic ->> still binds as the JSON operator whenever the previous statement ends in an expression, so SELECT 1 ->> SELECT 2 and SELECT * FROM t WHERE a = 1 ->> SELECT 1 fail while SELECT * FROM t ->> SELECT 1 works. Either drop Generic here or add a test documenting the partial support.
| /// Used in FROM clauses of pipe-chained statements to reference previous results. | ||
| /// See <https://docs.snowflake.com/en/sql-reference/operators-flow> | ||
| PipeResultScan { | ||
| /// 1-based index of the previous statement whose result is referenced. |
There was a problem hiding this comment.
Worth saying this counts back from the current statement ($1 is the immediately preceding one, $2 the one before that), since index reads as absolute.
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