datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

Incorrect type coercion rule for date + interval

Open waitingkuo opened this issue 2 years ago • 1 comments

Describe the bug A clear and concise description of what the bug is.

coercion rule for date + interval('1 day' ) works but fails for hours/min/sec

To Reproduce Steps to reproduce the behavior:

❯ select now()::date + interval '1 hour';
+----------------------------------------------------+
| CAST(now() AS Date32) + IntervalDayTime("3600000") |
+----------------------------------------------------+
| +11879-01-27                                       |
+----------------------------------------------------+
1 row in set. Query took 0.000 seconds.

Expected behavior A clear and concise description of what you expected to happen.

Cast to Timestamp like what postgresql does

willy=# select now()::date + interval '1 hour';
      ?column?       
---------------------
 2022-08-10 01:00:00
(1 row)

Additional context Add any other context about the problem here.

waitingkuo avatar Aug 10 '22 07:08 waitingkuo

related issue/pr: #194 #2235

waitingkuo avatar Aug 10 '22 07:08 waitingkuo

My reproduce

❯ select now()::date + interval '1 hour';
+----------------------------------------------------+
| CAST(now() AS Date32) + IntervalDayTime("3600000") |
+----------------------------------------------------+
| 2022-08-12                                         |
+----------------------------------------------------+

JasonLi-cn avatar Aug 12 '22 01:08 JasonLi-cn

@JasonLi-cn thank you, looks like this is solved in some pr. I'll close this issue as this is similar as #3103 now.

waitingkuo avatar Aug 12 '22 02:08 waitingkuo