Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion docs/sql-data-sources-jdbc.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ logging into the data sources.
<td>read/write</td>
</tr>
<tr>
<td><code>inferTimestampNTZType</code></td>
<td><code>preferTimestampNTZ</code></td>
<td>false</td>
<td>
When the option is set to <code>true</code>, all timestamps are inferred as TIMESTAMP WITHOUT TIME ZONE.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ class JDBCOptions(
val prepareQuery = parameters.get(JDBC_PREPARE_QUERY).map(_ + " ").getOrElse("")

// Infers timestamp values as TimestampNTZ type when reading data.
val inferTimestampNTZType =
val preferTimestampNTZ =
parameters
.get(JDBC_INFER_TIMESTAMP_NTZ)
.get(JDBC_PREFER_TIMESTAMP_NTZ)
.map(_.toBoolean)
.getOrElse(SQLConf.get.timestampType == TimestampNTZType)
}
Expand Down Expand Up @@ -301,5 +301,5 @@ object JDBCOptions {
val JDBC_REFRESH_KRB5_CONFIG = newOption("refreshKrb5Config")
val JDBC_CONNECTION_PROVIDER = newOption("connectionProvider")
val JDBC_PREPARE_QUERY = newOption("prepareQuery")
val JDBC_INFER_TIMESTAMP_NTZ = newOption("inferTimestampNTZType")
val JDBC_PREFER_TIMESTAMP_NTZ = newOption("preferTimestampNTZ")
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ object JDBCRDD extends Logging {
val rs = statement.executeQuery()
try {
JdbcUtils.getSchema(rs, dialect, alwaysNullable = true,
isTimestampNTZ = options.inferTimestampNTZType)
isTimestampNTZ = options.preferTimestampNTZ)
} finally {
rs.close()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ object JdbcUtils extends Logging with SQLConfHelper {
try {
statement.setQueryTimeout(options.queryTimeout)
Some(getSchema(statement.executeQuery(), dialect,
isTimestampNTZ = options.inferTimestampNTZType))
isTimestampNTZ = options.preferTimestampNTZ))
} catch {
case _: SQLException => None
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1951,7 +1951,7 @@ class JDBCSuite extends QueryTest with SharedSparkSession {
} else {
TimestampType
}
val res = readDf.option("inferTimestampNTZType", inferTimestampNTZ).load()
val res = readDf.option("preferTimestampNTZ", inferTimestampNTZ).load()
checkAnswer(res, Seq(Row(null)))
assert(res.schema.fields.head.dataType == tsType)
withSQLConf(SQLConf.TIMESTAMP_TYPE.key -> timestampType) {
Expand Down Expand Up @@ -1984,7 +1984,7 @@ class JDBCSuite extends QueryTest with SharedSparkSession {
DateTimeTestUtils.withDefaultTimeZone(zoneId) {
// Infer TimestmapNTZ column with data source option
val res = spark.read.format("jdbc")
.option("inferTimestampNTZType", "true")
.option("preferTimestampNTZ", "true")
.option("url", urlWithUserAndPass)
.option("dbtable", tableName)
.load()
Expand Down