GitHub user attilapiros opened a pull request:

    https://github.com/apache/spark/pull/23000

    [SPARK-26002][SQL] Fix day of year calculation for Julian calendar days

    ## What changes were proposed in this pull request?
    
    Fixing leap year calculations for date operators (year/month/dayOfYear) 
where the Julian calendars are used (before 1582-10-04). In a Julian calendar 
every years which are multiples of 4 are leap years (there is no extra 
exception for years multiples of 100).  
    
    ## How was this patch tested?
    
    With a unit test ("SPARK-26002: correct day of year calculations for Julian 
calendar years") which focuses to these corner cases.
    
    Manually:
    
    ```
    scala> sql("select year('1500-01-01')").show()
    
    +------------------------------+
    |year(CAST(1500-01-01 AS DATE))|
    +------------------------------+
    |                          1500|
    +------------------------------+
    
    scala> sql("select dayOfYear('1100-01-01')").show()
    
    +-----------------------------------+
    |dayofyear(CAST(1100-01-01 AS DATE))|
    +-----------------------------------+
    |                                  1|
    +-----------------------------------+
    ```


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/attilapiros/spark julianOffByDays

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/23000.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #23000
    
----
commit f2bc0b26184c02b6019893c601eb479db9419689
Author: “attilapiros” <piros.attila.zsolt@...>
Date:   2018-11-10T13:28:01Z

    Fix day of year calculation for Julian calendar days

----


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to