Fixed CHANGES keyword parsing for snowflake#2266
Open
romanoff wants to merge 4 commits intoapache:mainfrom
Open
Fixed CHANGES keyword parsing for snowflake#2266romanoff wants to merge 4 commits intoapache:mainfrom
romanoff wants to merge 4 commits intoapache:mainfrom
Conversation
iffyio
reviewed
Mar 9, 2026
src/ast/query.rs
Outdated
| /// When the table version is defined using a function. | ||
| /// For example: `SELECT * FROM tbl AT(TIMESTAMP => '2020-08-14 09:30:00')` | ||
| Function(Expr), | ||
| /// Snowflake CHANGES clause for change tracking queries. |
Contributor
There was a problem hiding this comment.
Suggested change
| /// Snowflake CHANGES clause for change tracking queries. | |
| /// Snowflake `CHANGES` clause for change tracking queries. |
src/parser/mod.rs
Outdated
Comment on lines
+16279
to
+16290
| // Snowflake CHANGES clause: | ||
| // CHANGES(INFORMATION => ...) AT(...) [END(...)] | ||
| let changes_name = self.parse_object_name(true)?; | ||
| let changes = self.parse_function(changes_name)?; | ||
| let at_name = self.parse_object_name(true)?; | ||
| let at = self.parse_function(at_name)?; | ||
| let end = if self.peek_keyword(Keyword::END) { | ||
| let end_name = self.parse_object_name(true)?; | ||
| Some(self.parse_function(end_name)?) | ||
| } else { | ||
| None | ||
| }; |
Contributor
There was a problem hiding this comment.
can we pull the logic out into its own function?
src/parser/mod.rs
Outdated
Comment on lines
+16279
to
+16280
| // Snowflake CHANGES clause: | ||
| // CHANGES(INFORMATION => ...) AT(...) [END(...)] |
Contributor
There was a problem hiding this comment.
Suggested change
| // Snowflake CHANGES clause: | |
| // CHANGES(INFORMATION => ...) AT(...) [END(...)] |
tests/sqlparser_snowflake.rs
Outdated
| fn test_changes_clause() { | ||
| // CHANGES with AT and END | ||
| snowflake().verified_stmt( | ||
| "SELECT a FROM \"PCH_ODS_FIDELIO\".\"SRC_VW_SYS_ACC_MASTER\" CHANGES(INFORMATION => DEFAULT) AT(TIMESTAMP => TO_TIMESTAMP_TZ('2026-02-18 11:23:19.660000000')) END(TIMESTAMP => TO_TIMESTAMP_TZ('2026-02-18 11:38:30.211000000'))", |
Contributor
There was a problem hiding this comment.
can we use r#""# syntax to avoid escaping the quotes in the string?
Contributor
Author
|
@iffyio Updated. Thank you |
8c8fe43 to
00c2698
Compare
00c2698 to
319af8b
Compare
Contributor
Author
|
Had to add https://github.com/apache/datafusion-sqlparser-rs/pull/2266/changes#diff-80f1d10500bf0503869a8a33086830849ab5455192c0269291eefb70d11911e3L3211-R3214 due to failing tests on CI |
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.
Query example:
Spec: https://docs.snowflake.com/en/sql-reference/constructs/changes