Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interval Literal output inconsistent date_type #3180

Closed
Tracked by #3148
waitingkuo opened this issue Aug 16, 2022 · 1 comment
Closed
Tracked by #3148

Interval Literal output inconsistent date_type #3180

waitingkuo opened this issue Aug 16, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@waitingkuo
Copy link
Contributor

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

the output of INTERVAL XXX is inconsistent

To Reproduce
Steps to reproduce the behavior:

while we only have year or month, it outputs IntervalYearMonth

select interval '1 year';
+------------------------------------------------+
| IntervalYearMonth("12")                        |
+------------------------------------------------+
| 1 years 0 mons 0 days 0 hours 0 mins 0.00 secs |
+------------------------------------------------+
1 row in set. Query took 0.001 seconds.
❯ select interval '1 year 1 month';
+------------------------------------------------+
| IntervalYearMonth("13")                        |
+------------------------------------------------+
| 1 years 1 mons 0 days 0 hours 0 mins 0.00 secs |
+------------------------------------------------+

while we have (year or month) and any other unit, it outputs IntervalMonthDayNano

+--------------------------------------------------------+
| IntervalMonthDayNano("950737950189618795196236955648") |
+--------------------------------------------------------+
| 0 years 12 mons 1 days 0 hours 0 mins 0.00 secs        |
+--------------------------------------------------------+
1 row in set. Query took 0.001 seconds.
❯ select interval '1 year 1 second';
+--------------------------------------------------------+
| IntervalMonthDayNano("950737950171172051123527404032") |
+--------------------------------------------------------+
| 0 years 12 mons 0 days 0 hours 0 mins 1.00 secs        |
+--------------------------------------------------------+
1 row in set. Query took 0.001 seconds.

Otherwise, it outputs IntervalDaytime

select interval '1 second';
+------------------------------------------------+
| IntervalDayTime("1000")                        |
+------------------------------------------------+
| 0 years 0 mons 0 days 0 hours 0 mins 1.00 secs |
+------------------------------------------------+
1 row in set. Query took 0.001 seconds.
❯ select interval '1 day 1 second';
+------------------------------------------------+
| IntervalDayTime("4294968296")                  |
+------------------------------------------------+
| 0 years 0 mons 1 days 0 hours 0 mins 1.00 secs |
+------------------------------------------------+
1 row in set. Query took 0.001 seconds.

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

they should be consistent, as our current Timestamp is in nanosecond, i suggest using IntervalMonthDayNano. We could consider add functions to output specific data type(i.e. to_interval_monthdaynano(), to_interval_daytime(), interval_yearmonth() . But i think they might need different arithmetics

Additional context
Add any other context about the problem here.

@waitingkuo
Copy link
Contributor Author

just found that it's designed in purpose. let me close this and fire another ticket for discussing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant