Skip to content

Commit

Permalink
Support 'timezone_region' for EXTRACT and DATE_PART
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie committed Jan 12, 2024
1 parent ce49886 commit 8aed07f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ast/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ pub enum DateTimeField {
Timezone,
TimezoneHour,
TimezoneMinute,
TimezoneRegion,
NoDateTime,
}

Expand Down Expand Up @@ -183,6 +184,7 @@ impl fmt::Display for DateTimeField {
DateTimeField::Timezone => "TIMEZONE",
DateTimeField::TimezoneHour => "TIMEZONE_HOUR",
DateTimeField::TimezoneMinute => "TIMEZONE_MINUTE",
DateTimeField::TimezoneRegion => "TIMEZONE_REGION",
DateTimeField::NoDateTime => "NODATETIME",
})
}
Expand Down
1 change: 1 addition & 0 deletions src/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ define_keywords!(
TIMEZONE,
TIMEZONE_HOUR,
TIMEZONE_MINUTE,
TIMEZONE_REGION,
TINYINT,
TO,
TOP,
Expand Down
1 change: 1 addition & 0 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,7 @@ impl<'a> Parser<'a> {
Keyword::TIMEZONE => Ok(DateTimeField::Timezone),
Keyword::TIMEZONE_HOUR => Ok(DateTimeField::TimezoneHour),
Keyword::TIMEZONE_MINUTE => Ok(DateTimeField::TimezoneMinute),
Keyword::TIMEZONE_REGION => Ok(DateTimeField::TimezoneRegion),
_ => self.expected("date/time field", next_token),
},
_ => self.expected("date/time field", next_token),
Expand Down
1 change: 1 addition & 0 deletions tests/sqlparser_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2240,6 +2240,7 @@ fn parse_extract() {
verified_stmt("SELECT EXTRACT(TIMEZONE FROM d)");
verified_stmt("SELECT EXTRACT(TIMEZONE_HOUR FROM d)");
verified_stmt("SELECT EXTRACT(TIMEZONE_MINUTE FROM d)");
verified_stmt("SELECT EXTRACT(TIMEZONE_REGION FROM d)");
verified_stmt("SELECT EXTRACT(TIME FROM d)");

let res = parse_sql_statements("SELECT EXTRACT(JIFFY FROM d)");
Expand Down

0 comments on commit 8aed07f

Please sign in to comment.