yaooqinn commented on issue #26418: [SPARK-29783][SQL] Support SQL 
Standard/ISO_8601 output style for interval type
URL: https://github.com/apache/spark/pull/26418#issuecomment-552946152
 
 
   > We can't change the behavior of multi-unit syntax as it has been there for 
a long time, and the pgsql behavior is really confusing.
   
   yes, so we use the SQL standard for display only.
   
   > 
   > AFAIK the SQL standard only allows one leading `-` in the year-month or 
day-time interval string, which is difficult for us to follow: how can we 
represent 1 day - 3 hour?
   
   ```sql
   postgres=# set IntervalStyle=sql_standard;
   SET
   postgres=# select interval '-1 year -1 day -1 hour';
        interval
   ------------------
    -1-0 -1 -1:00:00
   (1 row)
   
   postgres=# select interval '-1 year 1 day 1 hour';
        interval
   ------------------
    -1-0 -1 -1:00:00
   (1 row)
   
   postgres=# select interval '-1 year 1 day +1 hour';
        interval
   ------------------
    -1-0 +1 +1:00:00
   (1 row)
   
   postgres=# select interval '+1 year 1 day +1 hour';
        interval
   ------------------
    +1-0 +1 +1:00:00
   (1 row)
   ```
   
   One proper way is that we add explicit signs for each part to eliminate 
ambiguity as shown in the above cases.
   
   So in that case,  `1 day - 3 hour` will be `+1 -3:00:00`.
   
   
   

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

Reply via email to