Skip to content

INTERVAL + timestamp and INTERVAL + date not supported (but timestamp + INTERVAL and date + INTERVAL is) #6180

Closed

Description

@jackwener

Describe the bug

current df don't support interval in left.

select interval '1 month' + '2023-05-01'::date;

This feature is not implemented: Unsupported interval argument. Expected string literal, got: BinaryOp { left: Value(SingleQuotedString("1 month")), op: Plus, right: Cast { expr: Value(SingleQuotedString("2023-05-01")), data_type: Date } }

To Reproduce

No response

Expected behavior

No response

Additional context

No response

Activity

  1. jackwener commented on May 1, 2023

    @jackwener
    MemberAuthor

    It's wrong in src/expr/mod.rs:140 sql_interval_to_expr().

    SQLExpr is

    "Interval { value: BinaryOp { left: Value(SingleQuotedString("1 month")), op: Plus, right: Cast { expr: Value(SingleQuotedString("2023-05-01")), data_type: Date } }, leading_field: None, leading_precision: None, last_field: None, fractional_seconds_precision: None }"

    I think it is a bug in Parser. Interval shouldn't include BinaryOp.

  2. alamb commented on May 1, 2023

    @alamb
    Contributor

    Added to #5753

  3. changed the title [-]Don't support Interval is in left.[/-] [+]`INTERVAL` + timestamp and `INTERVAL` + date not supported (but timestamp + `INTERVAL` and date + `INTERVAL` is)[/+] on May 1, 2023
  4. alamb commented on May 3, 2023

    @alamb
    Contributor

    I agree this is a parser problem. INTERVAL + timestamp and INTERVAL+date do work if the ::interval cast syntax is used rather than the interval. I will open another bug explaining this

    ❯ select '1 month'::interval + '2012-01-01'::date;
    +--------------------------------------+
    | Utf8("1 month") + Utf8("2012-01-01") |
    +--------------------------------------+
    | 2012-02-01                           |
    +--------------------------------------+
    ❯ select '1 month'::interval + '2012-01-01'::timestamp;
    +--------------------------------------+
    | Utf8("1 month") + Utf8("2012-01-01") |
    +--------------------------------------+
    | 2012-02-01T00:00:00                  |
    +--------------------------------------+
    
    ❯ select '2012-01-01'::date + interval '1 month';
    +----------------------------------------------------------------------------+
    | Utf8("2012-01-01") + IntervalMonthDayNano("79228162514264337593543950336") |
    +----------------------------------------------------------------------------+
    | 2012-02-01                                                                 |
    +----------------------------------------------------------------------------+
    
    ❯ select interval '1 month' + '2012-01-01'::date;
    This feature is not implemented: Unsupported interval argument. Expected string literal, got: BinaryOp { left: Value(SingleQuotedString("1 month")), op: Plus, right: Cast { expr: Value(SingleQuotedString("2012-01-01")), data_type: Date } }
    
  5. alamb commented on May 3, 2023

    @alamb
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions