MaxGekk opened a new pull request #26355: [SPARK-29651][SQL][2.4] Fix parsing of interval seconds fraction URL: https://github.com/apache/spark/pull/26355 ### What changes were proposed in this pull request? In the PR, I propose to extract parsing of the seconds interval units to the private method `parseNanos` in `CalendarInterval` and modify the code to correctly parse the fractional part of the seconds unit of intervals in the cases: - When the fractional part has less than 9 digits - The seconds unit is negative This is a back port of the commit https://github.com/apache/spark/commit/3206a9987001d78cf2f48509a93d73af86f51cfe. ### Why are the changes needed? The changes are needed to fix the issues: ```sql spark-sql> select interval 10.123456 seconds; interval 10 seconds 123 microseconds ``` The correct result must be `interval 10 seconds 123 milliseconds 456 microseconds` ```sql spark-sql> select interval -10.123456789 seconds; interval -9 seconds -876 milliseconds -544 microseconds ``` but the whole interval should be negated, and the result must be `interval -10 seconds -123 milliseconds -456 microseconds`, taking into account the truncation to microseconds. ### Does this PR introduce any user-facing change? Yes. After changes: ```sql spark-sql> select interval 10.123456 seconds; interval 10 seconds 123 milliseconds 456 microseconds spark-sql> select interval -10.123456789 seconds; interval -10 seconds -123 milliseconds -456 microseconds ``` ### How was this patch tested? By existing test suite, `literals.sql` and new tests in `ExpressionParserSuite`.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
