mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-25 08:24:05 +00:00
feat: Support LOCALTIME
and LOCALTIMESTAMP
time functions (#592)
This commit is contained in:
parent
bccd63ea07
commit
0bb49cea99
2 changed files with 37 additions and 1 deletions
|
@ -438,7 +438,11 @@ impl<'a> Parser<'a> {
|
||||||
special: true,
|
special: true,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
Keyword::CURRENT_TIMESTAMP | Keyword::CURRENT_TIME | Keyword::CURRENT_DATE => {
|
Keyword::CURRENT_TIMESTAMP
|
||||||
|
| Keyword::CURRENT_TIME
|
||||||
|
| Keyword::CURRENT_DATE
|
||||||
|
| Keyword::LOCALTIME
|
||||||
|
| Keyword::LOCALTIMESTAMP => {
|
||||||
self.parse_time_functions(ObjectName(vec![w.to_ident()]))
|
self.parse_time_functions(ObjectName(vec![w.to_ident()]))
|
||||||
}
|
}
|
||||||
Keyword::CASE => self.parse_case_expr(),
|
Keyword::CASE => self.parse_case_expr(),
|
||||||
|
|
|
@ -5353,6 +5353,38 @@ fn parse_time_functions() {
|
||||||
|
|
||||||
// Validating Parenthesis
|
// Validating Parenthesis
|
||||||
one_statement_parses_to("SELECT CURRENT_DATE", sql);
|
one_statement_parses_to("SELECT CURRENT_DATE", sql);
|
||||||
|
|
||||||
|
let sql = "SELECT LOCALTIME()";
|
||||||
|
let select = verified_only_select(sql);
|
||||||
|
assert_eq!(
|
||||||
|
&Expr::Function(Function {
|
||||||
|
name: ObjectName(vec![Ident::new("LOCALTIME")]),
|
||||||
|
args: vec![],
|
||||||
|
over: None,
|
||||||
|
distinct: false,
|
||||||
|
special: false,
|
||||||
|
}),
|
||||||
|
expr_from_projection(&select.projection[0])
|
||||||
|
);
|
||||||
|
|
||||||
|
// Validating Parenthesis
|
||||||
|
one_statement_parses_to("SELECT LOCALTIME", sql);
|
||||||
|
|
||||||
|
let sql = "SELECT LOCALTIMESTAMP()";
|
||||||
|
let select = verified_only_select(sql);
|
||||||
|
assert_eq!(
|
||||||
|
&Expr::Function(Function {
|
||||||
|
name: ObjectName(vec![Ident::new("LOCALTIMESTAMP")]),
|
||||||
|
args: vec![],
|
||||||
|
over: None,
|
||||||
|
distinct: false,
|
||||||
|
special: false,
|
||||||
|
}),
|
||||||
|
expr_from_projection(&select.projection[0])
|
||||||
|
);
|
||||||
|
|
||||||
|
// Validating Parenthesis
|
||||||
|
one_statement_parses_to("SELECT LOCALTIMESTAMP", sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue