Skip to content

Commit

Permalink
improve test queality
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoPhilipse committed Jun 15, 2020
1 parent 5f06714 commit 8fe1960
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 10 deletions.
Empty file.
@@ -0,0 +1 @@
1.0
Empty file.

This file was deleted.

@@ -0,0 +1 @@
-1.0
Empty file.

This file was deleted.

Expand Up @@ -180,8 +180,7 @@ class HiveQuerySuite extends HiveComparisonTest with SQLTestUtils with BeforeAnd
"SELECT CAST(CAST('NaN' AS DOUBLE) AS DECIMAL(1,1)) FROM src LIMIT 1")

createQueryTest("constant null testing",
"""set spark.sql.legacy.allowCastNumericToTimestamp=true;
| SELECT
"""| SELECT
|IF(FALSE, CAST(NULL AS STRING), CAST(1 AS STRING)) AS COL1,
|IF(TRUE, CAST(NULL AS STRING), CAST(1 AS STRING)) AS COL2,
|IF(FALSE, CAST(NULL AS INT), CAST(1 AS INT)) AS COL3,
Expand All @@ -202,13 +201,14 @@ class HiveQuerySuite extends HiveComparisonTest with SQLTestUtils with BeforeAnd
|IF(TRUE, CAST(NULL AS BINARY), CAST("1" AS BINARY)) AS COL18,
|IF(FALSE, CAST(NULL AS DATE), CAST("1970-01-01" AS DATE)) AS COL19,
|IF(TRUE, CAST(NULL AS DATE), CAST("1970-01-01" AS DATE)) AS COL20,
|IF(TRUE, CAST(NULL AS TIMESTAMP), CAST(1 AS TIMESTAMP)) AS COL21,
|IF(TRUE, CAST(NULL AS TIMESTAMP), CAST('1969-12-31 16:00:01' AS TIMESTAMP)) AS COL21,
|IF(FALSE, CAST(NULL AS DECIMAL), CAST(1 AS DECIMAL)) AS COL22,
|IF(TRUE, CAST(NULL AS DECIMAL), CAST(1 AS DECIMAL)) AS COL23
|FROM src LIMIT 1""".stripMargin)

test("constant null testing timestamp") {
val r1 = sql("SELECT IF(FALSE, CAST(NULL AS TIMESTAMP), TIMESTAMP_SECONDS(1)) AS COL20")
val r1 = sql("SELECT IF(FALSE, CAST(NULL AS TIMESTAMP)," +
"CAST('1969-12-31 16:00:01' AS TIMESTAMP)) AS COL20")
.collect().head
assert(new Timestamp(1000) == r1.getTimestamp(0))
}
Expand Down Expand Up @@ -564,14 +564,12 @@ class HiveQuerySuite extends HiveComparisonTest with SQLTestUtils with BeforeAnd

createQueryTest("timestamp cast #3",
"""
|set spark.sql.legacy.allowCastNumericToTimestamp=true;
|SELECT CAST(CAST(1.2 AS TIMESTAMP) AS DOUBLE) FROM src LIMIT 1
|SELECT CAST(TIMESTAMP_SECONDS(CAST(1.2 AS INT)) AS DOUBLE) FROM src LIMIT 1
""".stripMargin)

createQueryTest("timestamp cast #4",
"""
|set spark.sql.legacy.allowCastNumericToTimestamp=true;
|SELECT CAST(CAST(-1.2 AS TIMESTAMP) AS DOUBLE) FROM src LIMIT 1
|SELECT CAST(TIMESTAMP_SECONDS(CAST(-1.2 AS INT)) AS DOUBLE) FROM src LIMIT 1
""".stripMargin)

test("timestamp cast #5") {
Expand Down

0 comments on commit 8fe1960

Please sign in to comment.