Skip to content

timestamp - interval results in The type of Timestamp(Nanosecond, Some("+00:00")) Minus Utf8 of binary physical should be same #5650

Description

@alamb

Describe the bug
I ran a query and got an internal error

To Reproduce
Using datafusion-cli:

❯ create table foo(x timestamp) as select '2023-03-01'::timestamp;
0 rows in set. Query took 0.002 seconds.
❯ select * from foo;
+---------------------+
| x                   |
+---------------------+
| 2023-03-01T00:00:00 |
+---------------------+
1 row in set. Query took 0.001 seconds.
❯ select * from foo where x < now() - '1 day';
The type of Timestamp(Nanosecond, Some("+00:00")) Minus Utf8 of binary physical should be same. This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

Note it is possible to use the interval syntax things work out correctly

❯ select * from foo where x < now() - interval '1 day';
+---------------------+
| x                   |
+---------------------+
| 2023-03-01T00:00:00 |
+---------------------+

Note if you try to use the same predicate outside of the where clause, we get a planning error (correctly):

❯ select now()  - '1 day';
Error during planning: 'Timestamp(Nanosecond, Some("+00:00")) - Utf8' can't be evaluated because there isn't a common type to coerce the types to

Expected behavior

  1. (minimum) select * from foo where x < now() - '1 day'; should produce a planning error (rather than an internal error)
  2. (ideal) Make the query work

Additional context

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