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

Bug parsing interval with negative values #4237

Closed
waitingkuo opened this issue Nov 16, 2022 · 4 comments · Fixed by #4238
Closed

Bug parsing interval with negative values #4237

waitingkuo opened this issue Nov 16, 2022 · 4 comments · Fixed by #4238
Labels
bug Something isn't working

Comments

@waitingkuo
Copy link
Contributor

waitingkuo commented Nov 16, 2022

Describe the bug

bug parsing interval that contains negative values

To Reproduce

select (interval '1 month -1 second');
+---------------------------------------------------+
| IntervalMonthDayNano("-1000000000")               |
+---------------------------------------------------+
| 0 years -1 mons -1 days 0 hours 0 mins -1.00 secs |
+---------------------------------------------------+
1 row in set. Query took 0.002 seconds.

this is a parsing issue but not a display issue, underline value is incorrect IntervalMonthDayNano("-1000000000")

Expected behavior

0 year 1 mons 0 days 0 hours 0 mins -1 secs

Additional context

https://github.com/apache/arrow-datafusion/blob/406c1087bc16f8d2a49e5a9b05d2a0e1b67f7aa5/datafusion/common/src/parsers.rs#L151-L152

the binary expression for result nanos (which is 128bit long here) is 111111111111111......... which make months and days becomes negative

negative factional seconds has display issue #4220

@waitingkuo
Copy link
Contributor Author

cc @alamb @Jefffrey @tustvold

@Jefffrey
Copy link
Contributor

Thanks for finding this, looks like its not only limited to the nanoseconds portion of IntervalMonthDayNano, but its day portion, as well as the day bits of IntervalDayTime as well

I'll raise a PR for this soon

@alamb
Copy link
Contributor

alamb commented Nov 16, 2022

Wow ⏩ @Jefffrey !

@waitingkuo
Copy link
Contributor Author

thank you @Jefffrey

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

Successfully merging a pull request may close this issue.

3 participants