-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-28432][SQL] Add make_date function
#25210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
65ce7ea
ccd7d59
1906e04
60f5627
d25e74d
c82428c
2b257d0
6b632dc
fea2621
a57754c
24fa82a
318cc18
a5ef08b
e92beea
8def6c3
30e62c2
646456b
639c6b0
15c64d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| -- Automatically generated by SQLQueryTestSuite | ||
| -- Number of queries: 48 | ||
| -- Number of queries: 53 | ||
|
|
||
|
|
||
| -- !query 0 | ||
|
|
@@ -508,8 +508,48 @@ struct<Days From 2K:int> | |
|
|
||
|
|
||
| -- !query 47 | ||
| DROP TABLE DATE_TBL | ||
| select make_date(2013, 7, 15) | ||
| -- !query 47 schema | ||
| struct<> | ||
| struct<make_date(2013, 7, 15):date> | ||
| -- !query 47 output | ||
| 2013-07-15 | ||
|
|
||
|
|
||
| -- !query 48 | ||
| select make_date(-44, 3, 15) | ||
| -- !query 48 schema | ||
| struct<make_date(-44, 3, 15):date> | ||
| -- !query 48 output | ||
| 0045-03-15 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The year scala> spark.conf.set("spark.sql.datetime.java8API.enabled", true)
scala> spark.sql("select make_date(-44, 3, 15)").collect
res7: Array[org.apache.spark.sql.Row] = Array([-0044-03-15])the returned instance of
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to file a JIRA issue for this difference on FYI, the following is PostgreSQL output.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, the reason for the difference here is how Spark converts internal type For spark.conf.set("spark.sql.datetime.java8API.enabled", false)
val date = spark.sql("select make_date(-44, 3, 15)").first.getAs[java.sql.Date](0)
val sdf = new java.text.SimpleDateFormat("MM-dd-yyyy G")
scala> sdf.format(date)
res18: String = 03-17-0045 BCFor Java8 spark.conf.set("spark.sql.datetime.java8API.enabled", true)
val formatter = DateTimeFormatter.ofPattern("MM-dd-yyyy G")
val localDate = spark.sql("select make_date(-44, 3, 15)").first.getAs[LocalDate](0)
localDate.format(formatter)
res16: String = 03-15-0045 BCThe difference in days due to difference calendars (Julian in the first case, and Proleptic Gregorian in the second one). I see Postgres formats the I don't think we should implement Postgres bugs.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, what I mean is we need a JIRA report and JIRA ID comment because we don't follow PostgreSQL like that.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, you can file a PostgreSQL bug and use that instead of SPARK JIRA.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the JIRA ticket: https://issues.apache.org/jira/browse/SPARK-28471 |
||
|
|
||
|
|
||
| -- !query 49 | ||
| select make_date(2013, 2, 30) | ||
| -- !query 49 schema | ||
| struct<make_date(2013, 2, 30):date> | ||
| -- !query 49 output | ||
| NULL | ||
|
|
||
|
|
||
| -- !query 50 | ||
| select make_date(2013, 13, 1) | ||
| -- !query 50 schema | ||
| struct<make_date(2013, 13, 1):date> | ||
| -- !query 50 output | ||
| NULL | ||
|
|
||
|
|
||
| -- !query 51 | ||
| select make_date(2013, 11, -1) | ||
| -- !query 51 schema | ||
| struct<make_date(2013, 11, -1):date> | ||
| -- !query 51 output | ||
| NULL | ||
|
|
||
|
|
||
| -- !query 52 | ||
| DROP TABLE DATE_TBL | ||
| -- !query 52 schema | ||
| struct<> | ||
| -- !query 52 output | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.