Skip to content
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
4 changes: 4 additions & 0 deletions src/ast/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ pub enum DateTimeField {
Millennium,
Millisecond,
Milliseconds,
Nanosecond,
Nanoseconds,
Comment on lines +94 to +95
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add new DateTimeFields

Quarter,
Timezone,
TimezoneHour,
Expand Down Expand Up @@ -123,6 +125,8 @@ impl fmt::Display for DateTimeField {
DateTimeField::Millennium => "MILLENNIUM",
DateTimeField::Millisecond => "MILLISECOND",
DateTimeField::Milliseconds => "MILLISECONDS",
DateTimeField::Nanosecond => "NANOSECOND",
DateTimeField::Nanoseconds => "NANOSECONDS",
DateTimeField::Quarter => "QUARTER",
DateTimeField::Timezone => "TIMEZONE",
DateTimeField::TimezoneHour => "TIMEZONE_HOUR",
Expand Down
2 changes: 2 additions & 0 deletions src/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ define_keywords!(
MSCK,
MULTISET,
MUTATION,
NANOSECOND,
NANOSECONDS,
Comment on lines +364 to +365
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add new keywords (follows the ascending order)

NATIONAL,
NATURAL,
NCHAR,
Expand Down
4 changes: 4 additions & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,8 @@ impl<'a> Parser<'a> {
Keyword::MILLENNIUM => Ok(DateTimeField::Millennium),
Keyword::MILLISECOND => Ok(DateTimeField::Millisecond),
Keyword::MILLISECONDS => Ok(DateTimeField::Milliseconds),
Keyword::NANOSECOND => Ok(DateTimeField::Nanosecond),
Keyword::NANOSECONDS => Ok(DateTimeField::Nanoseconds),
Keyword::QUARTER => Ok(DateTimeField::Quarter),
Keyword::TIMEZONE => Ok(DateTimeField::Timezone),
Keyword::TIMEZONE_HOUR => Ok(DateTimeField::TimezoneHour),
Expand Down Expand Up @@ -1343,6 +1345,8 @@ impl<'a> Parser<'a> {
Keyword::MILLENNIUM,
Keyword::MILLISECOND,
Keyword::MILLISECONDS,
Keyword::NANOSECOND,
Keyword::NANOSECONDS,
Keyword::QUARTER,
Keyword::TIMEZONE,
Keyword::TIMEZONE_HOUR,
Expand Down
3 changes: 3 additions & 0 deletions tests/sqlparser_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,9 @@ fn parse_extract() {
verified_stmt("SELECT EXTRACT(HOUR FROM d)");
verified_stmt("SELECT EXTRACT(MINUTE FROM d)");
verified_stmt("SELECT EXTRACT(SECOND FROM d)");
verified_stmt("SELECT EXTRACT(MILLISECOND FROM d)");
verified_stmt("SELECT EXTRACT(MICROSECOND FROM d)");
verified_stmt("SELECT EXTRACT(NANOSECOND FROM d)");
Comment on lines +1743 to +1745
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test cases

verified_stmt("SELECT EXTRACT(CENTURY FROM d)");
verified_stmt("SELECT EXTRACT(DECADE FROM d)");
verified_stmt("SELECT EXTRACT(DOW FROM d)");
Expand Down