support "set time zone to 'some-timezone'"#617
Merged
alamb merged 3 commits intoapache:mainfrom Sep 20, 2022
Merged
Conversation
waitingkuo
commented
Sep 19, 2022
src/parser.rs
Outdated
Comment on lines
3777
to
3782
| let variable = if self.parse_keywords(&vec![Keyword::TIME, Keyword::ZONE]) { | ||
| ObjectName(vec!["TIMEZONE".into()]) | ||
| } else { | ||
| self.parse_object_name()? | ||
| }; | ||
|
|
Contributor
Author
There was a problem hiding this comment.
before parse_object_name, try to parse 'TIME ZONE' to see whether it works
Contributor
Author
There was a problem hiding this comment.
if it works, combine TIME and ZONE to TIMEZONE
waitingkuo
commented
Sep 19, 2022
8c5dab2 to
9b44dcc
Compare
waitingkuo
commented
Sep 19, 2022
Comment on lines
+4686
to
+4707
| #[test] | ||
| fn parse_set_time_zone() { | ||
| match verified_stmt("SET TIMEZONE = 'UTC'") { | ||
| Statement::SetVariable { | ||
| local, | ||
| hivevar, | ||
| variable, | ||
| value, | ||
| } => { | ||
| assert!(!local); | ||
| assert!(!hivevar); | ||
| assert_eq!(variable, ObjectName(vec!["TIMEZONE".into()])); | ||
| assert_eq!( | ||
| value, | ||
| vec![Expr::Value(Value::SingleQuotedString("UTC".into()))] | ||
| ); | ||
| } | ||
| _ => unreachable!(), | ||
| } | ||
|
|
||
| one_statement_parses_to("SET TIME ZONE TO 'UTC'", "SET TIMEZONE = 'UTC'"); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
test case for both TIME ZONE and TIMEZONE
Pull Request Test Coverage Report for Build 3084544815
💛 - Coveralls |
Contributor
Author
|
@avantgardnerio @alamb this could enable |
avantgardnerio
approved these changes
Sep 19, 2022
avantgardnerio
left a comment
There was a problem hiding this comment.
I don't know this crate very well, but I like what you're doing :)
alamb
approved these changes
Sep 20, 2022
Contributor
alamb
left a comment
There was a problem hiding this comment.
LGTM -- thanks @waitingkuo
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.
close #303
sqlparser-rs original only supports
SET TIMEZONE = 'some-timezone'now.there're many dbs support both
TIMEZONEandTIME ZONEin the SET statement (e.g. postgresql, pyspark, ...)this pr is to enable
SET TIMEZONE = 'some-timezone'