Skip to content

Commit 7668405

Browse files
committed
Fix other tests
1 parent de06515 commit 7668405

File tree

4 files changed

+36
-32
lines changed

4 files changed

+36
-32
lines changed

sql/core/src/test/resources/sql-tests/results/ansi/literals.sql.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,9 @@ cannot resolve '(+ TIMESTAMP '1999-01-01 00:00:00')' due to data type mismatch:
451451
-- !query
452452
select +interval '1 day'
453453
-- !query schema
454-
struct<(+ INTERVAL '1 days'):interval>
454+
struct<(+ INTERVAL '1 00:00:00' DAY TO SECOND):day-time interval>
455455
-- !query output
456-
1 days
456+
1 00:00:00.000000000
457457

458458

459459
-- !query

sql/core/src/test/resources/sql-tests/results/literals.sql.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,9 @@ cannot resolve '(+ TIMESTAMP '1999-01-01 00:00:00')' due to data type mismatch:
451451
-- !query
452452
select +interval '1 day'
453453
-- !query schema
454-
struct<(+ INTERVAL '1 days'):interval>
454+
struct<(+ INTERVAL '1 00:00:00' DAY TO SECOND):day-time interval>
455455
-- !query output
456-
1 days
456+
1 00:00:00.000000000
457457

458458

459459
-- !query

sql/core/src/test/resources/sql-tests/results/misc-functions.sql.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ float double decimal(2,1)
3737
-- !query
3838
select typeof(date '1986-05-23'), typeof(timestamp '1986-05-23'), typeof(interval '23 days')
3939
-- !query schema
40-
struct<typeof(DATE '1986-05-23'):string,typeof(TIMESTAMP '1986-05-23 00:00:00'):string,typeof(INTERVAL '23 days'):string>
40+
struct<typeof(DATE '1986-05-23'):string,typeof(TIMESTAMP '1986-05-23 00:00:00'):string,typeof(INTERVAL '23 00:00:00' DAY TO SECOND):string>
4141
-- !query output
42-
date timestamp interval
42+
date timestamp day-time interval
4343

4444

4545
-- !query

sql/core/src/test/scala/org/apache/spark/sql/DateFunctionsSuite.scala

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -292,35 +292,39 @@ class DateFunctionsSuite extends QueryTest with SharedSparkSession {
292292
}
293293

294294
test("time_add") {
295-
val t1 = Timestamp.valueOf("2015-07-31 23:59:59")
296-
val t2 = Timestamp.valueOf("2015-12-31 00:00:00")
297-
val d1 = Date.valueOf("2015-07-31")
298-
val d2 = Date.valueOf("2015-12-31")
299-
val i = new CalendarInterval(2, 2, 2000000L)
300-
val df = Seq((1, t1, d1), (3, t2, d2)).toDF("n", "t", "d")
301-
checkAnswer(
302-
df.selectExpr(s"d + INTERVAL'${i.toString}'"),
303-
Seq(Row(Date.valueOf("2015-10-02")), Row(Date.valueOf("2016-03-02"))))
304-
checkAnswer(
305-
df.selectExpr(s"t + INTERVAL'${i.toString}'"),
306-
Seq(Row(Timestamp.valueOf("2015-10-03 00:00:01")),
307-
Row(Timestamp.valueOf("2016-03-02 00:00:02"))))
295+
withSQLConf(SQLConf.LEGACY_INTERVAL_ENABLED.key -> "true") {
296+
val t1 = Timestamp.valueOf("2015-07-31 23:59:59")
297+
val t2 = Timestamp.valueOf("2015-12-31 00:00:00")
298+
val d1 = Date.valueOf("2015-07-31")
299+
val d2 = Date.valueOf("2015-12-31")
300+
val i = new CalendarInterval(2, 2, 2000000L)
301+
val df = Seq((1, t1, d1), (3, t2, d2)).toDF("n", "t", "d")
302+
checkAnswer(
303+
df.selectExpr(s"d + INTERVAL'${i.toString}'"),
304+
Seq(Row(Date.valueOf("2015-10-02")), Row(Date.valueOf("2016-03-02"))))
305+
checkAnswer(
306+
df.selectExpr(s"t + INTERVAL'${i.toString}'"),
307+
Seq(Row(Timestamp.valueOf("2015-10-03 00:00:01")),
308+
Row(Timestamp.valueOf("2016-03-02 00:00:02"))))
309+
}
308310
}
309311

310312
test("time_sub") {
311-
val t1 = Timestamp.valueOf("2015-10-01 00:00:01")
312-
val t2 = Timestamp.valueOf("2016-02-29 00:00:02")
313-
val d1 = Date.valueOf("2015-09-30")
314-
val d2 = Date.valueOf("2016-02-29")
315-
val i = new CalendarInterval(2, 2, 2000000L)
316-
val df = Seq((1, t1, d1), (3, t2, d2)).toDF("n", "t", "d")
317-
checkAnswer(
318-
df.selectExpr(s"d - INTERVAL'${i.toString}'"),
319-
Seq(Row(Date.valueOf("2015-07-27")), Row(Date.valueOf("2015-12-26"))))
320-
checkAnswer(
321-
df.selectExpr(s"t - INTERVAL'${i.toString}'"),
322-
Seq(Row(Timestamp.valueOf("2015-07-29 23:59:59")),
323-
Row(Timestamp.valueOf("2015-12-27 00:00:00"))))
313+
withSQLConf(SQLConf.LEGACY_INTERVAL_ENABLED.key -> "true") {
314+
val t1 = Timestamp.valueOf("2015-10-01 00:00:01")
315+
val t2 = Timestamp.valueOf("2016-02-29 00:00:02")
316+
val d1 = Date.valueOf("2015-09-30")
317+
val d2 = Date.valueOf("2016-02-29")
318+
val i = new CalendarInterval(2, 2, 2000000L)
319+
val df = Seq((1, t1, d1), (3, t2, d2)).toDF("n", "t", "d")
320+
checkAnswer(
321+
df.selectExpr(s"d - INTERVAL'${i.toString}'"),
322+
Seq(Row(Date.valueOf("2015-07-27")), Row(Date.valueOf("2015-12-26"))))
323+
checkAnswer(
324+
df.selectExpr(s"t - INTERVAL'${i.toString}'"),
325+
Seq(Row(Timestamp.valueOf("2015-07-29 23:59:59")),
326+
Row(Timestamp.valueOf("2015-12-27 00:00:00"))))
327+
}
324328
}
325329

326330
test("function make_interval") {

0 commit comments

Comments
 (0)