Skip to content
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

feat: support SET TIME ZONE INTERVAL '+00:00' HOUR TO MINUTE; #18705

Merged
merged 5 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions e2e_test/database/timezone.slt
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,11 @@ set time zone 12.3;

statement error
set time zone interval '1' hour;

# support a special case for clients which would send when initializing the connection
statement ok
SET TIME ZONE INTERVAL '+00:00' HOUR TO MINUTE;

# only support '+00:00'
statement error
SET TIME ZONE INTERVAL '+01:00' HOUR TO MINUTE;
20 changes: 20 additions & 0 deletions src/sqlparser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4289,6 +4289,26 @@ impl Parser<'_> {
let value = alt((
Keyword::DEFAULT.value(SetTimeZoneValue::Default),
Keyword::LOCAL.value(SetTimeZoneValue::Local),
preceded(
Keyword::INTERVAL,
cut_err(Self::parse_literal_interval.try_map(|e| match e {
// support a special case for clients which would send when initializing the connection
// like: SET TIME ZONE INTERVAL '+00:00' HOUR TO MINUTE;
Expr::Value(v) => match v {
Value::Interval { value, .. } => {
if value != "+00:00" {
return Err(StrError("only support \"+00:00\" ".into()));
}
Ok(SetTimeZoneValue::Ident(Ident::with_quote_unchecked(
'\'',
"UTC".to_string(),
)))
}
_ => Err(StrError("expect Value::Interval".into())),
},
_ => Err(StrError("expect Expr::Value".into())),
})),
),
Self::parse_identifier.map(SetTimeZoneValue::Ident),
Self::parse_value.map(SetTimeZoneValue::Literal),
))
Expand Down
Loading