Skip to content

Commit 7ba3cbb

Browse files
committed
Pass time zone as a parameter
1 parent 8bb4f3a commit 7ba3cbb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ private[sql] object JDBCRelation extends Logging {
8585
val (column, columnType) = verifyAndGetNormalizedPartitionColumn(
8686
schema, partitionColumn.get, resolver, jdbcOptions)
8787

88-
val lowerBoundValue = toInternalBoundValue(lowerBound.get, columnType)
89-
val upperBoundValue = toInternalBoundValue(upperBound.get, columnType)
88+
val lowerBoundValue = toInternalBoundValue(lowerBound.get, columnType, timeZoneId)
89+
val upperBoundValue = toInternalBoundValue(upperBound.get, columnType, timeZoneId)
9090
JDBCPartitioningInfo(
9191
column, columnType, lowerBoundValue, upperBoundValue, numPartitions.get)
9292
}
@@ -174,7 +174,10 @@ private[sql] object JDBCRelation extends Logging {
174174
(dialect.quoteIdentifier(column.name), column.dataType)
175175
}
176176

177-
private def toInternalBoundValue(value: String, columnType: DataType): Long = {
177+
private def toInternalBoundValue(
178+
value: String,
179+
columnType: DataType,
180+
timeZoneId: String): Long = {
178181
def parse[T](f: UTF8String => Option[T]): T = {
179182
f(UTF8String.fromString(value)).getOrElse {
180183
throw new IllegalArgumentException(
@@ -184,8 +187,7 @@ private[sql] object JDBCRelation extends Logging {
184187
columnType match {
185188
case _: NumericType => value.toLong
186189
case DateType => parse(stringToDate).toLong
187-
case TimestampType =>
188-
parse(stringToTimestamp(_, getTimeZone(SQLConf.get.sessionLocalTimeZone)))
190+
case TimestampType => parse(stringToTimestamp(_, getTimeZone(timeZoneId)))
189191
}
190192
}
191193

0 commit comments

Comments
 (0)