iffyio commented on code in PR #2266:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2266#discussion_r2904213203
##########
src/parser/mod.rs:
##########
@@ -16275,6 +16275,20 @@ impl<'a> Parser<'a> {
{
let expr = self.parse_expr()?;
return Ok(Some(TableVersion::ForSystemTimeAsOf(expr)));
+ } else if self.peek_keyword(Keyword::CHANGES) {
+ // 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
+ };
Review Comment:
can we pull the logic out into its own function?
##########
src/ast/query.rs:
##########
@@ -2578,6 +2578,23 @@ pub enum TableVersion {
/// 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.
Review Comment:
```suggestion
/// Snowflake `CHANGES` clause for change tracking queries.
```
##########
src/parser/mod.rs:
##########
@@ -16275,6 +16275,20 @@ impl<'a> Parser<'a> {
{
let expr = self.parse_expr()?;
return Ok(Some(TableVersion::ForSystemTimeAsOf(expr)));
+ } else if self.peek_keyword(Keyword::CHANGES) {
+ // Snowflake CHANGES clause:
+ // CHANGES(INFORMATION => ...) AT(...) [END(...)]
Review Comment:
```suggestion
```
##########
tests/sqlparser_snowflake.rs:
##########
@@ -3963,6 +3963,32 @@ fn test_timetravel_at_before() {
.verified_only_select("SELECT * FROM tbl BEFORE(TIMESTAMP =>
'2024-12-15 00:00:00')");
}
+#[test]
+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'))",
Review Comment:
can we use `r#""#` syntax to avoid escaping the quotes in the string?
--
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]