Skip to content
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

[KYUUBI #4316] Fix returned Timestamp values may lose precision #4318

Closed
wants to merge 9 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
nit
pan3793 committed Feb 14, 2023
commit 8be774b4f5f4e2aa78b8e180918b822dcf06e268
Original file line number Diff line number Diff line change
@@ -161,7 +161,8 @@ trait SparkDataTypeTests extends HiveJDBCTestHelper {

test("execute statement - select timestamp - second") {
withJdbcStatement() { statement =>
val resultSet = statement.executeQuery("SELECT TIMESTAMP '2018-11-17 13:33:33' AS col")
val resultSet = statement.executeQuery(
"SELECT TIMESTAMP '2018-11-17 13:33:33' AS col")
assert(resultSet.next())
assert(resultSet.getTimestamp("col") === Timestamp.valueOf("2018-11-17 13:33:33"))
val metaData = resultSet.getMetaData
@@ -173,7 +174,8 @@ trait SparkDataTypeTests extends HiveJDBCTestHelper {

test("execute statement - select timestamp - millisecond") {
withJdbcStatement() { statement =>
val resultSet = statement.executeQuery("SELECT TIMESTAMP '2018-11-17 13:33:33.12345' AS col")
val resultSet = statement.executeQuery(
"SELECT TIMESTAMP '2018-11-17 13:33:33.12345' AS col")
assert(resultSet.next())
assert(resultSet.getTimestamp("col") === Timestamp.valueOf("2018-11-17 13:33:33.12345"))
val metaData = resultSet.getMetaData
@@ -183,13 +185,26 @@ trait SparkDataTypeTests extends HiveJDBCTestHelper {
}
}

test("execute statement - select timestamp - overflow") {
withJdbcStatement() { statement =>
val resultSet = statement.executeQuery(
"SELECT TIMESTAMP '2018-11-17 13:33:33.1234567' AS col")
assert(resultSet.next())
assert(resultSet.getTimestamp("col") === Timestamp.valueOf("2018-11-17 13:33:33.123456"))
val metaData = resultSet.getMetaData
assert(metaData.getColumnType(1) === java.sql.Types.TIMESTAMP)
assert(metaData.getPrecision(1) === 29)
assert(metaData.getScale(1) === 9)
}
}

test("execute statement - select timestamp_ntz") {
assume(SPARK_ENGINE_VERSION >= "3.4")
withJdbcStatement() { statement =>
val resultSet = statement.executeQuery(
"SELECT make_timestamp_ntz(2022, 03, 24, 18, 08, 31.800) AS col")
"SELECT make_timestamp_ntz(2022, 03, 24, 18, 08, 31.8888) AS col")
assert(resultSet.next())
assert(resultSet.getTimestamp("col") === Timestamp.valueOf("2022-03-24 18:08:31.800"))
assert(resultSet.getTimestamp("col") === Timestamp.valueOf("2022-03-24 18:08:31.8888"))
val metaData = resultSet.getMetaData
assert(metaData.getColumnType(1) === java.sql.Types.TIMESTAMP)
assert(metaData.getPrecision(1) === 29)