-
Notifications
You must be signed in to change notification settings - Fork 576
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
Add a mutable visitor #782
Conversation
This adds the ability to mutate parsed sql queries. Previously, only visitors taking an immutable reference to the visited structures were allowed.
Pull Request Test Coverage Report for Build 3818810193
💛 - Coveralls |
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.
Looks good to me -- thank you @lovasoa
Happy new year to you as well 🌟
cc @tustvold and @AugustoFKL
Prior to releasing this code, I think we need to bump the version of the derive crate (semantically compatible), and make sqlparser depend on that higher version (to get the new derive_mut visitor)
@alamb, I think taking the values by ownership would require a significant amount of work, and not bring performance gains. |
I don't think I did a good job explaining the alternative The idea is to use something like https://github.com/apache/arrow-datafusion/blob/master/datafusion/expr/src/expr_rewriter.rs However, I don't feel strongly about it -- the mutation approach looks good to me.
Thank you 3ac3c67 looks good |
BTW I think the more appropriate comparison is with release mode, but even then the example is 2x slower with ownership https://play.rust-lang.org/?version=stable&mode=release&edition=2021 |
Great, thanks for merging! I'll use that in sqlpage. Do you think you can release a new version on crates.io soon? |
Yes I will go make one now |
Preparing one now: #786 |
Happy new year 🥳
This is a follow-up on #765 .
This adds the ability to mutate the AST as it is visited. I didn't remove the old immutable-only visitor trait.
Previously, only visitors taking an immutable reference to the visited structures were allowed.