mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-18 21:20:15 +00:00
fix: Support expr
instead of string
for argument to interval
(#517)
* fix: use expr instead of string in interval * chore: resolve CI Co-authored-by: togami2864 <yoshiaki.togami@plaid.co.jp>
This commit is contained in:
parent
99697d26e1
commit
d981f70143
3 changed files with 52 additions and 15 deletions
|
@ -994,6 +994,7 @@ impl<'a> Parser<'a> {
|
|||
/// 4. `INTERVAL '1:1:1.1' HOUR (5) TO SECOND (5)`
|
||||
/// 5. `INTERVAL '1.1' SECOND (2, 2)`
|
||||
/// 6. `INTERVAL '1:1' HOUR (5) TO MINUTE (5)`
|
||||
/// 7. (MySql and BigQuey only):`INTERVAL 1 DAY`
|
||||
///
|
||||
/// Note that we do not currently attempt to parse the quoted value.
|
||||
pub fn parse_literal_interval(&mut self) -> Result<Expr, ParserError> {
|
||||
|
@ -1004,13 +1005,13 @@ impl<'a> Parser<'a> {
|
|||
|
||||
// The first token in an interval is a string literal which specifies
|
||||
// the duration of the interval.
|
||||
let value = self.parse_literal_string()?;
|
||||
let value = self.parse_expr()?;
|
||||
|
||||
// Following the string literal is a qualifier which indicates the units
|
||||
// of the duration specified in the string literal.
|
||||
//
|
||||
// Note that PostgreSQL allows omitting the qualifier, so we provide
|
||||
// this more general implemenation.
|
||||
// this more general implementation.
|
||||
let leading_field = match self.peek_token() {
|
||||
Token::Word(kw)
|
||||
if [
|
||||
|
@ -1071,7 +1072,7 @@ impl<'a> Parser<'a> {
|
|||
};
|
||||
|
||||
Ok(Expr::Value(Value::Interval {
|
||||
value,
|
||||
value: Box::new(value),
|
||||
leading_field,
|
||||
leading_precision,
|
||||
last_field,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue