You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jackwener (via GitHub)" <gi...@apache.org> on 2023/04/03 13:47:33 UTC

[GitHub] [arrow-datafusion] jackwener commented on a diff in pull request #5806: Fix `interval` to use consistent units and arrow parser

jackwener commented on code in PR #5806:
URL: https://github.com/apache/arrow-datafusion/pull/5806#discussion_r1155989213


##########
datafusion/core/tests/sql/expr.rs:
##########
@@ -843,153 +843,153 @@ async fn test_interval_expressions() -> Result<()> {
     // day nano intervals
     test_expression!(
         "interval '1'",
-        "0 years 0 mons 0 days 0 hours 0 mins 1.000 secs"
+        "0 years 0 mons 0 days 0 hours 0 mins 1.000000000 secs"
     );
     test_expression!(
         "interval '1 second'",
-        "0 years 0 mons 0 days 0 hours 0 mins 1.000 secs"
+        "0 years 0 mons 0 days 0 hours 0 mins 1.000000000 secs"
     );
     test_expression!(
         "interval '500 milliseconds'",
-        "0 years 0 mons 0 days 0 hours 0 mins 0.500 secs"
+        "0 years 0 mons 0 days 0 hours 0 mins 0.500000000 secs"
     );
     test_expression!(
         "interval '5 second'",
-        "0 years 0 mons 0 days 0 hours 0 mins 5.000 secs"
+        "0 years 0 mons 0 days 0 hours 0 mins 5.000000000 secs"
     );
     test_expression!(
         "interval '0.5 minute'",
-        "0 years 0 mons 0 days 0 hours 0 mins 30.000 secs"
+        "0 years 0 mons 0 days 0 hours 0 mins 30.000000000 secs"
     );
     test_expression!(
         "interval '.5 minute'",
-        "0 years 0 mons 0 days 0 hours 0 mins 30.000 secs"
+        "0 years 0 mons 0 days 0 hours 0 mins 30.000000000 secs"
     );
     test_expression!(
         "interval '5 minute'",
-        "0 years 0 mons 0 days 0 hours 5 mins 0.000 secs"
+        "0 years 0 mons 0 days 0 hours 5 mins 0.000000000 secs"
     );
     test_expression!(
         "interval '5 minute 1 second'",
-        "0 years 0 mons 0 days 0 hours 5 mins 1.000 secs"
+        "0 years 0 mons 0 days 0 hours 5 mins 1.000000000 secs"
     );
     test_expression!(
         "interval '1 hour'",
-        "0 years 0 mons 0 days 1 hours 0 mins 0.000 secs"
+        "0 years 0 mons 0 days 1 hours 0 mins 0.000000000 secs"
     );
     test_expression!(
         "interval '5 hour'",
-        "0 years 0 mons 0 days 5 hours 0 mins 0.000 secs"
+        "0 years 0 mons 0 days 5 hours 0 mins 0.000000000 secs"
     );
     test_expression!(
         "interval '1 day'",
-        "0 years 0 mons 1 days 0 hours 0 mins 0.000 secs"
+        "0 years 0 mons 1 days 0 hours 0 mins 0.000000000 secs"
     );
     test_expression!(
         "interval '1 week'",
-        "0 years 0 mons 7 days 0 hours 0 mins 0.000 secs"
+        "0 years 0 mons 7 days 0 hours 0 mins 0.000000000 secs"
     );
     test_expression!(
         "interval '2 weeks'",
-        "0 years 0 mons 14 days 0 hours 0 mins 0.000 secs"
+        "0 years 0 mons 14 days 0 hours 0 mins 0.000000000 secs"
     );
     test_expression!(
         "interval '1 day 1'",
-        "0 years 0 mons 1 days 0 hours 0 mins 1.000 secs"
+        "0 years 0 mons 1 days 0 hours 0 mins 1.000000000 secs"
     );
     test_expression!(
         "interval '0.5'",
-        "0 years 0 mons 0 days 0 hours 0 mins 0.500 secs"
+        "0 years 0 mons 0 days 0 hours 0 mins 0.500000000 secs"
     );
     test_expression!(
         "interval '0.5 day 1'",
-        "0 years 0 mons 0 days 12 hours 0 mins 1.000 secs"
+        "0 years 0 mons 0 days 12 hours 0 mins 1.000000000 secs"
     );
     test_expression!(
         "interval '0.49 day'",
-        "0 years 0 mons 0 days 11 hours 45 mins 36.000 secs"
+        "0 years 0 mons 0 days 11 hours 45 mins 36.000000000 secs"
     );
     test_expression!(
         "interval '0.499 day'",
-        "0 years 0 mons 0 days 11 hours 58 mins 33.600 secs"
+        "0 years 0 mons 0 days 11 hours 58 mins 33.600000000 secs"
     );
     test_expression!(
         "interval '0.4999 day'",
-        "0 years 0 mons 0 days 11 hours 59 mins 51.360 secs"
+        "0 years 0 mons 0 days 11 hours 59 mins 51.360000000 secs"
     );
     test_expression!(
         "interval '0.49999 day'",
-        "0 years 0 mons 0 days 11 hours 59 mins 59.136 secs"
+        "0 years 0 mons 0 days 11 hours 59 mins 59.136000000 secs"
     );
     test_expression!(
         "interval '0.49999999999 day'",
         "0 years 0 mons 0 days 11 hours 59 mins 59.999999136 secs"
     );
     test_expression!(
         "interval '5 day'",
-        "0 years 0 mons 5 days 0 hours 0 mins 0.000 secs"
+        "0 years 0 mons 5 days 0 hours 0 mins 0.000000000 secs"
     );
     // Hour is ignored, this matches PostgreSQL
     test_expression!(
         "interval '5 day' hour",
-        "0 years 0 mons 5 days 0 hours 0 mins 0.000 secs"
+        "0 years 0 mons 5 days 0 hours 0 mins 0.000000000 secs"
     );
     test_expression!(
         "interval '5 day 4 hours 3 minutes 2 seconds 100 milliseconds'",
-        "0 years 0 mons 5 days 4 hours 3 mins 2.100 secs"
+        "0 years 0 mons 5 days 4 hours 3 mins 2.100000000 secs"
     );
     // month intervals
     test_expression!(
         "interval '0.5 month'",
-        "0 years 0 mons 15 days 0 hours 0 mins 0.000 secs"
+        "0 years 0 mons 15 days 0 hours 0 mins 0.000000000 secs"
     );
     test_expression!(
         "interval '0.5' month",
-        "0 years 0 mons 15 days 0 hours 0 mins 0.000 secs"
+        "0 years 0 mons 15 days 0 hours 0 mins 0.000000000 secs"
     );
     test_expression!(
         "interval '1 month'",
-        "0 years 1 mons 0 days 0 hours 0 mins 0.00 secs"
+        "0 years 1 mons 0 days 0 hours 0 mins 0.000000000 secs"
     );
     test_expression!(
         "interval '1' MONTH",
-        "0 years 1 mons 0 days 0 hours 0 mins 0.00 secs"
+        "0 years 1 mons 0 days 0 hours 0 mins 0.000000000 secs"
     );
     test_expression!(
         "interval '5 month'",
-        "0 years 5 mons 0 days 0 hours 0 mins 0.00 secs"
+        "0 years 5 mons 0 days 0 hours 0 mins 0.000000000 secs"
     );
     test_expression!(
         "interval '13 month'",
-        "1 years 1 mons 0 days 0 hours 0 mins 0.00 secs"
+        "0 years 13 mons 0 days 0 hours 0 mins 0.000000000 secs"

Review Comment:
   > FWIW this was a conscious change when the parsing logic was ported, to faithfully preserve what the user specified. This was mainly in the context of rounding days to months and hours to days, which were simply incorrect, but months to years got the same treatment
   
   Make sense to međź‘Ť



-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org