Uh oh!
There was an error while loading. Please reload this page.
[SPARK-20763][SQL]The function of month and day return the value which is not we expected. - #17997
[SPARK-20763][SQL]The function of month and day return the value which is not we expected.#1799710110346 wants to merge 2 commits into
month and day return the value which is not we expected.#17997Conversation
month and day return an error valuemonth and day return the value which is not we expected.srowen
commented
May 16, 2017
Point taken, but do other DBs support dates before 1970? it does highly depend on historical calendars. The right solution isn't a hack in one place here but using Calendar properly, if anything. |
10110346
commented
May 16, 2017
@srowen I have tested in mysql, it can support dates before 1970. mysql> select day("1582-04-18"); |
There was a problem hiding this comment.
this would cause massive performance regression.
There was a problem hiding this comment.
yes,this cause performance worse than before
3f2d8d6 to
a8d6e04Compareueshin
commented
May 17, 2017
I guess this would also affect date-related functions such as |
10110346
commented
May 17, 2017
@ueshin Yes, I will do it ,thanks |
There was a problem hiding this comment.
I believe the dates we need to test here should be the boundaries like 1582-10-04 and 1582-10-15.
Btw, let's add 0 for 1-digit date, e.g. 1582-10-04 instead of 1582-10-4.
There was a problem hiding this comment.
Here should be 1581-12-31 and 1582-01-01, for example, and the rest should be in a similar way.
There was a problem hiding this comment.
How about using 1582-09-30 and 1582-10-01 for this?
There was a problem hiding this comment.
I'm not sure whether this value is correct or not. should be 278?
There was a problem hiding this comment.
I'm not sure too, maybe 278 is better
There was a problem hiding this comment.
can we check with other databases?
There was a problem hiding this comment.
@cloud-fan In mysql ,the rusult is :
mysql> select dayofyear("1982-10-04");
+-------------------------+
| dayofyear("1982-10-04") |
+-------------------------+
| 277 |
+-------------------------+
1 row in set (0.00 sec)
mysql> select dayofyear("1982-10-15");
+--------------------------+
| dayofyear("1982-10-15") |
+--------------------------+
| 288 |
+--------------------------+
There was a problem hiding this comment.
@cloud-fan Because in history,the period(5.10.1582 ~ 14.10.1582) is not exist.
But maybe 288 is more human readable.
There was a problem hiding this comment.
nit: this representation may be confusing for all of the people in the world. Can we use 1582-10-5 or like Oct. 5, 1582?
There was a problem hiding this comment.
It's only about comment, and I think 1582-10-5 or Oct. 5, 1582 is more human readable.
There was a problem hiding this comment.
In history,the period(5.10.1582 ~ 14.10.1582) is not exist
->Since Julian calendar was replaced with the Gregorian calendar, the 10 days after Oct. 4 were skipped.
205d3d0 to
8c99316Compareueshin
commented
May 18, 2017
ok to test |
There was a problem hiding this comment.
In history,the period(5.10.1582 ~ 14.10.1582) is not exist
->Since Julian calendar was replaced with the Gregorian calendar, the 10 days after Oct. 4 were skipped.
gatorsmile
commented
May 18, 2017
The current impl is still missing the special handling of that miracle period. See the outputs of Oracle: |
@gatorsmile I have tested like this: Also,i tested in mysql: mysql> select dayofyear('1582-10-5'); mysql> select dayofyear('1582-10-6'); mysql> select dayofyear('1582-10-14'); mysql> select dayofyear('1582-10-15'); |
gatorsmile
commented
May 19, 2017
After checking DB2, it behaves the same as MySQL. LGTM |
… which is not we expected.
## What changes were proposed in this pull request?
spark-sql>select month("1582-09-28");
spark-sql>10
For this case, the expected result is 9, but it is 10.
spark-sql>select day("1582-04-18");
spark-sql>28
For this case, the expected result is 18, but it is 28.
when the date before "1582-10-04", the function of `month` and `day` return the value which is not we expected.
## How was this patch tested?
unit tests
Author: liuxian <liu.xian3@zte.com.cn>
Closes#17997 from 10110346/wip_lx_0516.
(cherry picked from commit ea3b1e3)
Signed-off-by: Xiao Li <gatorsmile@gmail.com>gatorsmile
commented
May 19, 2017
Thanks! Merging to master/2.2. |
gatorsmile
commented
May 19, 2017
Could you submit a backport PR to 2.1? Thanks! |
10110346
commented
May 19, 2017
OK,l Will do it, thanks. @gatorsmile |
…turn the value which is not we expected. What changes were proposed in this pull request? This PR is to backport #17997 to Spark 2.1 when the date before "1582-10-04", the function of month and day return the value which is not we expected. How was this patch tested? unit tests Author: liuxian <liu.xian3@zte.com.cn> Closes#18054 from 10110346/wip-lx-0522.
… which is not we expected.
## What changes were proposed in this pull request?
spark-sql>select month("1582-09-28");
spark-sql>10
For this case, the expected result is 9, but it is 10.
spark-sql>select day("1582-04-18");
spark-sql>28
For this case, the expected result is 18, but it is 28.
when the date before "1582-10-04", the function of `month` and `day` return the value which is not we expected.
## How was this patch tested?
unit tests
Author: liuxian <liu.xian3@zte.com.cn>
Closesapache#17997 from 10110346/wip_lx_0516.
What changes were proposed in this pull request?
spark-sql>select month("1582-09-28");
spark-sql>10
For this case, the expected result is 9, but it is 10.
spark-sql>select day("1582-04-18");
spark-sql>28
For this case, the expected result is 18, but it is 28.
when the date before "1582-10-04", the function of
monthanddayreturn the value which is not we expected.How was this patch tested?
unit tests