-
Notifications
You must be signed in to change notification settings - Fork 676
Databricks: Support Timetravel With "TIMESTAMP AS OF" #2134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Databricks: Support Timetravel With "TIMESTAMP AS OF" #2134
Conversation
src/parser/mod.rs
Outdated
| let func_name = self.parse_object_name(true)?; | ||
| let func = self.parse_function(func_name)?; | ||
| return Ok(Some(TableVersion::Function(func))); | ||
| } else if dialect_of!(self is DatabricksDialect) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should use the defined supports_timestamp_versioning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think relying on supports_timestamp_versioning alone might be insufficient. Please help me understand the desired behavior, I'm pretty new to the project.
The reason that I think that supports_timestamp_versioning may be insufficient on its own is that if we rely exclusively on that function to decide whether we parse TIMESTAMP AS OF syntax, then it will become available in the BigQuery dialect (and Snowflake, and MSSQL) - incorrectly. This is the reason I added an assertion to the BigQuery time travel test, looking for an error when TIMESTAMP AS OF is used.
In fact, I think what I have in this PR is also insufficient. If I use valid Snowflake time travel syntax (SELECT * FROM tbl AT(TIMESTAMP => '2024-12-15 00:00:00')), it's being accepted by the Databricks dialect. Instead, I would expect the Databricks dialect to throw an error (AT... is not valid time travel syntax in Databricks.)
Please help me understand the desired behavior here. Am I right to expect that an error should be thrown in the cases mentioned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To demonstrate my thinking here, I've added the following 2 commits, which result in two failing tests:
- b353499 --
sqlparse_bigquery::parse_table_timetravelfails after this commit - 759406f --
sqlparse_databricks::parse_table_timetravelfails after this commit
Are these failures valid, or is my expectation incorrect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah its fine for the parser to be permissive and accept sql statements for a dialect that wouldn't necessarily be supported by the dialect (downstream crates are expected to validate the returned AST if the behavior is undesirable for a specific use case), so that e.g. having bigquery accept the 'TIMESTAMP AS OF' would be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
This PR adds support for Databricks' timstamp-based time travel. This is a first step toward resolvign #2006.
The following is now supported: