attilapiros commented on issue #23000: [SPARK-26002][SQL] Fix day of year 
calculation for Julian calendar days
URL: https://github.com/apache/spark/pull/23000#issuecomment-450830994
 
 
   @MaxGekk thanks for the explanation, but I still a bit uncertain.  
   
   My main intention was about correcting the *dayOfYear/month/year* operators 
as the result in the following example are very strange (and not consistent 
with PostgreSQL too):
   ```
   scala> sql("select year('1500-01-01')").show()
   +------------------------------+
   |year(CAST(1500-01-01 AS DATE))|
   +------------------------------+
   |                          1499|
   +------------------------------+
   
   scala> sql("select month('1500-01-01')").show()
   +-------------------------------+
   |month(CAST(1500-01-01 AS DATE))|
   +-------------------------------+
   |                             12|
   +-------------------------------+
   
   
   scala> sql("select dayOfYear('1500-01-01')").show()
   +-----------------------------------+
   |dayofyear(CAST(1500-01-01 AS DATE))|
   +-----------------------------------+
   |                                365|
   +-----------------------------------+
   ```
   
   Running the corresponding expressions in PostgreSQL 9.6:
   ```
   >    SELECT DATE_PART('year', TIMESTAMP '1500-01-01 0:0:0') as "year";
   
   | year |
   | ---- |
   | 1500 |
   
   >   SELECT DATE_PART('month', TIMESTAMP '1500-01-01 0:0:0') as "month";
   
   | month |
   | ----- |
   | 1     |
   
   >  SELECT DATE_PART('doy', TIMESTAMP '1500-01-01 0:0:0') as "doy";
   
   | doy |
   | --- |
   | 1   |
   ```
    [View on DB Fiddle](https://www.db-fiddle.com/f/4rLEmF3xJjZqSaqA3h74Ky/1)
   
   Is there any other DBMS I can take as a reference?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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