For some strange reason , the dayofmonth
function in spark seems to return strange value for years 1500 or less
.
Following were the results that was obtained ->
scala> spark.sql("SELECT dayofmonth('1501-02-14') ").show()
+------------------------------------+
|dayofmonth(CAST(1501-02-14 AS DATE))|
+------------------------------------+
| 14|
+------------------------------------+
scala> spark.sql("SELECT dayofmonth('1500-02-14') ").show()
+------------------------------------+
|dayofmonth(CAST(1500-02-14 AS DATE))|
+------------------------------------+
| 13|
+------------------------------------+
scala> spark.sql("SELECT dayofmonth('1400-02-14') ").show()
+------------------------------------+
|dayofmonth(CAST(1400-02-14 AS DATE))|
+------------------------------------+
| 12|
+------------------------------------+
Can anyone explain , why spark behaves this way?