Skip to content

Fixed CHANGES keyword parsing for snowflake#2266

Open
romanoff wants to merge 4 commits intoapache:mainfrom
romanoff:fix_changes_parsing_for_snowflake
Open

Fixed CHANGES keyword parsing for snowflake#2266
romanoff wants to merge 4 commits intoapache:mainfrom
romanoff:fix_changes_parsing_for_snowflake

Conversation

@romanoff
Copy link
Contributor

@romanoff romanoff commented Mar 4, 2026

Query example:

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'));

Spec: https://docs.snowflake.com/en/sql-reference/constructs/changes

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Snowflake CHANGES clause for change tracking queries.
/// Snowflake `CHANGES` clause for change tracking queries.

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
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we pull the logic out into its own function?

Comment on lines +16279 to +16280
// Snowflake CHANGES clause:
// CHANGES(INFORMATION => ...) AT(...) [END(...)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Snowflake CHANGES clause:
// CHANGES(INFORMATION => ...) AT(...) [END(...)]

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'))",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use r#""# syntax to avoid escaping the quotes in the string?

@romanoff
Copy link
Contributor Author

romanoff commented Mar 9, 2026

@iffyio Updated. Thank you

@romanoff romanoff force-pushed the fix_changes_parsing_for_snowflake branch from 8c8fe43 to 00c2698 Compare March 9, 2026 23:58
@romanoff romanoff force-pushed the fix_changes_parsing_for_snowflake branch from 00c2698 to 319af8b Compare March 10, 2026 00:06
@romanoff
Copy link
Contributor Author

romanoff commented Mar 10, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants