Skip to content

Commit a360d5d

Browse files
gengliangwangdongjoon-hyun
authored andcommitted
[SPARK-42455][SQL] Rename JDBC option inferTimestampNTZType as preferTimestampNTZ
Similar with apache#37327, this PR renames the JDBC data source option `inferTimestampNTZType` as `preferTimestampNTZ` It is simpler and more straightforward. Also, it is consistent with the CSV data source option introduced in apache#37327, No, the TimestampNTZ project is not released yet. UT Closes apache#40042 from gengliangwang/inferNTZOption. Authored-by: Gengliang Wang <gengliang@apache.org> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org> (cherry picked from commit 8194522) Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
1 parent 284fdde commit a360d5d

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

docs/sql-data-sources-jdbc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ logging into the data sources.
365365
<td>read/write</td>
366366
</tr>
367367
<tr>
368-
<td><code>inferTimestampNTZType</code></td>
368+
<td><code>preferTimestampNTZ</code></td>
369369
<td>false</td>
370370
<td>
371371
When the option is set to <code>true</code>, all timestamps are inferred as TIMESTAMP WITHOUT TIME ZONE.

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ class JDBCOptions(
234234
val prepareQuery = parameters.get(JDBC_PREPARE_QUERY).map(_ + " ").getOrElse("")
235235

236236
// Infers timestamp values as TimestampNTZ type when reading data.
237-
val inferTimestampNTZType =
237+
val preferTimestampNTZ =
238238
parameters
239-
.get(JDBC_INFER_TIMESTAMP_NTZ)
239+
.get(JDBC_PREFER_TIMESTAMP_NTZ)
240240
.map(_.toBoolean)
241241
.getOrElse(SQLConf.get.timestampType == TimestampNTZType)
242242
}
@@ -301,5 +301,5 @@ object JDBCOptions {
301301
val JDBC_REFRESH_KRB5_CONFIG = newOption("refreshKrb5Config")
302302
val JDBC_CONNECTION_PROVIDER = newOption("connectionProvider")
303303
val JDBC_PREPARE_QUERY = newOption("prepareQuery")
304-
val JDBC_INFER_TIMESTAMP_NTZ = newOption("inferTimestampNTZType")
304+
val JDBC_PREFER_TIMESTAMP_NTZ = newOption("preferTimestampNTZ")
305305
}

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRDD.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ object JDBCRDD extends Logging {
6868
val rs = statement.executeQuery()
6969
try {
7070
JdbcUtils.getSchema(rs, dialect, alwaysNullable = true,
71-
isTimestampNTZ = options.inferTimestampNTZType)
71+
isTimestampNTZ = options.preferTimestampNTZ)
7272
} finally {
7373
rs.close()
7474
}

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ object JdbcUtils extends Logging with SQLConfHelper {
251251
try {
252252
statement.setQueryTimeout(options.queryTimeout)
253253
Some(getSchema(statement.executeQuery(), dialect,
254-
isTimestampNTZ = options.inferTimestampNTZType))
254+
isTimestampNTZ = options.preferTimestampNTZ))
255255
} catch {
256256
case _: SQLException => None
257257
} finally {

sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,7 +1951,7 @@ class JDBCSuite extends QueryTest with SharedSparkSession {
19511951
} else {
19521952
TimestampType
19531953
}
1954-
val res = readDf.option("inferTimestampNTZType", inferTimestampNTZ).load()
1954+
val res = readDf.option("preferTimestampNTZ", inferTimestampNTZ).load()
19551955
checkAnswer(res, Seq(Row(null)))
19561956
assert(res.schema.fields.head.dataType == tsType)
19571957
withSQLConf(SQLConf.TIMESTAMP_TYPE.key -> timestampType) {
@@ -1984,7 +1984,7 @@ class JDBCSuite extends QueryTest with SharedSparkSession {
19841984
DateTimeTestUtils.withDefaultTimeZone(zoneId) {
19851985
// Infer TimestmapNTZ column with data source option
19861986
val res = spark.read.format("jdbc")
1987-
.option("inferTimestampNTZType", "true")
1987+
.option("preferTimestampNTZ", "true")
19881988
.option("url", urlWithUserAndPass)
19891989
.option("dbtable", tableName)
19901990
.load()

0 commit comments

Comments
 (0)