-
Notifications
You must be signed in to change notification settings - Fork 558
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
support "set time zone to 'some-timezone'" #617
Conversation
src/parser.rs
Outdated
let variable = if self.parse_keywords(&vec![Keyword::TIME, Keyword::ZONE]) { | ||
ObjectName(vec!["TIMEZONE".into()]) | ||
} else { | ||
self.parse_object_name()? | ||
}; | ||
|
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.
before parse_object_name
, try to parse 'TIME ZONE' to see whether it works
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.
if it works, combine TIME
and ZONE
to TIMEZONE
8c5dab2
to
9b44dcc
Compare
#[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'"); | ||
} |
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.
test case for both TIME ZONE
and TIMEZONE
Pull Request Test Coverage Report for Build 3084544815
💛 - Coveralls |
@avantgardnerio @alamb this could enable |
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 don't know this crate very well, but I like what you're doing :)
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.
LGTM -- thanks @waitingkuo
close #303
sqlparser-rs original only supports
SET TIMEZONE = 'some-timezone'
now.there're many dbs support both
TIMEZONE
andTIME ZONE
in the SET statement (e.g. postgresql, pyspark, ...)this pr is to enable
SET TIMEZONE = 'some-timezone'