You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "Vedin (via GitHub)" <gi...@apache.org> on 2025/06/19 13:08:53 UTC

[PR] fix: parse snowflake fetch clause [datafusion-sqlparser-rs]

Vedin opened a new pull request, #1894:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1894

   Snowflake treat `FETCH` in a different way. https://docs.snowflake.com/en/sql-reference/constructs/limit
   Most keywords like `FIRST/NEXT`, `ROW/ROWS` and `ONLY` can be skipped.
   `PERSENT` and `WITH TIES` should cause an error. 


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: parse snowflake fetch clause [datafusion-sqlparser-rs]

Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio commented on code in PR #1894:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1894#discussion_r2163067879


##########
src/parser/mod.rs:
##########
@@ -15018,6 +15018,9 @@ impl<'a> Parser<'a> {
 
     /// Parse a FETCH clause
     pub fn parse_fetch(&mut self) -> Result<Fetch, ParserError> {
+        if dialect_of!(self is SnowflakeDialect) {
+            return self.parse_snowflake_fetch();
+        }

Review Comment:
   Yeah in some cases like this the parser may accept syntax that is more permissive than the configured dialect allows, and downstream crates are expected to validate the returned AST if necessary before consuming



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: parse snowflake fetch clause [datafusion-sqlparser-rs]

Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio merged PR #1894:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1894


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: parse snowflake fetch clause [datafusion-sqlparser-rs]

Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio commented on code in PR #1894:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1894#discussion_r2159884911


##########
src/parser/mod.rs:
##########
@@ -15018,6 +15018,9 @@ impl<'a> Parser<'a> {
 
     /// Parse a FETCH clause
     pub fn parse_fetch(&mut self) -> Result<Fetch, ParserError> {
+        if dialect_of!(self is SnowflakeDialect) {
+            return self.parse_snowflake_fetch();
+        }

Review Comment:
   It looks like the snowflake behavior is mostly a subset of the other dialects? If that's the case I think a reasonable approach would be to make the parser logic for the existing `parse_fetch` more permissive and accept the optional components regardless of dialect
   



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: parse snowflake fetch clause [datafusion-sqlparser-rs]

Posted by "Vedin (via GitHub)" <gi...@apache.org>.
Vedin commented on code in PR #1894:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1894#discussion_r2161623234


##########
src/parser/mod.rs:
##########
@@ -15018,6 +15018,9 @@ impl<'a> Parser<'a> {
 
     /// Parse a FETCH clause
     pub fn parse_fetch(&mut self) -> Result<Fetch, ParserError> {
+        if dialect_of!(self is SnowflakeDialect) {
+            return self.parse_snowflake_fetch();
+        }

Review Comment:
   I made `parse_fetch` more permissive. As I understood, the parser will allow wire syntax and skip some errors in other dialects. Is it a common way to fix such issues? Just want to know it for the future. 



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org