Skip to content

arithmetic operations on timestamps fail when now() is used as the LHS argument #6155

@kyle-mccarthy

Description

@kyle-mccarthy

Describe the bug

When performing an arithmetic operation on timestamps, now() causes an error when it is used as the LHS argument. It works as expected when it is used at the RHS argument.

Internal("If RHS of the operation is an array, then LHS also must be")

To Reproduce

The following will return an error and then panic on unwrap.

let ctx = SessionContext::new();

let df = ctx
    .sql(
        r#"
WITH cte AS (
    SELECT now() AS dt 
)
SELECT now() - cte.dt FROM cte
"#,
    )
    .await
    .unwrap();

Expected behavior

The operation should be successfully evaluated.

Additional context

The following will run without issue. Note that now() is the RHS arg in this sample.

let ctx = SessionContext::new();

let df = ctx
    .sql(
        r#"
WITH cte AS (
    SELECT now() AS dt 
)
SELECT cte.dt - now() FROM cte
"#,
    )
    .await
    .unwrap();

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions