You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "aprimadi (via GitHub)" <gi...@apache.org> on 2023/06/16 18:40:49 UTC

[GitHub] [arrow-datafusion] aprimadi commented on a diff in pull request #6698: fix: parser for negative intervals

aprimadi commented on code in PR #6698:
URL: https://github.com/apache/arrow-datafusion/pull/6698#discussion_r1232607304


##########
datafusion/core/tests/sqllogictests/test_files/interval.slt:
##########
@@ -190,25 +190,25 @@ select interval '1 year' - '1 month' - '1 day' - '1 hour' - '1 minute' - '1 seco
 query ?
 select -interval '5' - '1' - '2' year;
 ----
-0 years -24 mons 0 days 0 hours 0 mins 0.000000000 secs
+0 years -96 mons 0 days 0 hours 0 mins 0.000000000 secs

Review Comment:
   To me this doesn't look right. The previous test seems correct. When putting a negation in front of interval I believe it should negate the entire interval statement.
   
   `interval '5' - '1' - '2' year` is one interval statement.
   
   I think the statement
   
   ```
   select -interval '5' - '1' - '2' year;
   ```
   
   Should be interpreted as:
   
   ```
   select - (interval '5' - '1' - '2' year);
   ```
   
   Rather than
   
   ```
   select (- interval '5') - '1' - '2' year;
   ```
   
   If the user wants to negate only `5`, they should write it as follows:
   
   ```
   select interval - '5' - '1' - '2' year;
   ```
   
   Or:
   
   ```
   select - interval '5' year - interval '1' year - interval '2' year;
   ```
   
   Anyway, just my opinion.



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