Enable time travel for write statements with source queries#460
Merged
Conversation
gruuya
commented
Aug 14, 2023
Comment on lines
+990
to
+997
| // Create a mutable clone of the statement so that we can rewrite table names if we encounter | ||
| // time travel syntax. | ||
| // Alternatively, this could be done without the `mut`, except then we'd need to construct | ||
| // and return a new `DFStatement` after the rewrite. In case of `Statement::Query` this is | ||
| // straight-forward as that enum variant contains a struct, however `Statement::Insert` and | ||
| // `Statement::CreateTable` wrap dozens of fields in curly braces, and we'd need to capture | ||
| // and re-populate each of those, so it would be very verbose. | ||
| // TODO: If `sqlparser-rs` encapsulates these fields inside a struct at some point remove | ||
| // the mut and go with @ capture and de-structuring to pass along other fields unchanged. | ||
| let mut stmt = statement.clone(); |
Contributor
Author
There was a problem hiding this comment.
We already cloned the statement so that wont incur a time penalty. In theory the mut might, but I think it's negligible if any, given that it's local to a single function.
The alternative I mention is to have things as before and then capture and re-create a enum value with all the fields explicitly (since @ capture doesn't work in this case), i.e. https://github.com/sqlparser-rs/sqlparser-rs/blob/main/src/ast/mod.rs#L1178-L1198 for insert (even more verbose for create table).
mildbyte
approved these changes
Aug 14, 2023
1706983 to
fe5bc5d
Compare
fe5bc5d to
016f7b6
Compare
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.
Also moved the existing and the new time travel test into a separate file.
Closes #170.