Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c48a70d
Prepare for session local timezone support.
ueshin Dec 6, 2016
1d21fec
Make Cast TimeZoneAwareExpression.
ueshin Dec 6, 2016
0763c8f
Fix DateTimeUtilsSuite to follow changes.
ueshin Dec 6, 2016
449d93d
Make some datetime expressions TimeZoneAwareExpression.
ueshin Dec 8, 2016
b59d902
Fix compiler error in sql/core.
ueshin Dec 8, 2016
3ddfae4
Add constructors without zoneId to TimeZoneAwareExpressions for Funct…
ueshin Dec 9, 2016
f58f00d
Add DateTimeUtils.threadLocalLocalTimeZone to partition-reltated Cast.
ueshin Dec 13, 2016
8f2040b
Fix timezone for Hive timestamp string.
ueshin Dec 13, 2016
63c103c
Use defaultTimeZone instead of threadLocalLocalTimeZone.
ueshin Dec 13, 2016
7066850
Add TimeZone to DateFormats.
ueshin Dec 13, 2016
1aaca29
Make `CurrentBatchTimestamp` `TimeZoneAwareExpression`.
ueshin Dec 14, 2016
e5bb246
Add tests for date functions with session local timezone.
ueshin Dec 14, 2016
32cc391
Remove unused import and small cleanup.
ueshin Dec 16, 2016
f434378
Fix tests.
ueshin Dec 16, 2016
16fd1e4
Rename `zoneId` to `timeZoneId`.
ueshin Dec 19, 2016
009c17b
Use lazy val to avoid to keep creating a new timezone object (or doin…
ueshin Dec 19, 2016
a2936ed
Modify ComputeCurrentTime to hold the same date.
ueshin Dec 19, 2016
c5ca73e
Add comments.
ueshin Dec 19, 2016
b860379
Fix `Cast.needTimeZone()` to handle complex types.
ueshin Dec 19, 2016
6746265
Fix `Dataset.showString()` to use session local timezone.
ueshin Dec 19, 2016
4b6900c
Merge branch 'master' into issues/SPARK-18350
ueshin Dec 20, 2016
4f9cc40
Modify to analyze `ResolveTimeZone` only once.
ueshin Dec 24, 2016
2ca2413
Use session local timezone for Hive string.
ueshin Dec 24, 2016
c232854
Merge branch 'master' into issues/SPARK-18350
ueshin Dec 26, 2016
5b6dd4f
Merge branch 'master' into issues/SPARK-18350
ueshin Jan 5, 2017
1ca5808
Use `addReferenceMinorObj` to avoid adding member variables.
ueshin Jan 10, 2017
702dd81
Use Option[String] for timeZoneId.
ueshin Jan 10, 2017
33a3425
Update a comment.
ueshin Jan 10, 2017
5cc93e3
Fix overloaded constructors.
ueshin Jan 11, 2017
5521165
Fix session local timezone for timezone sensitive tests.
ueshin Jan 11, 2017
bd8275e
Remove `timeZoneResolved` and use `timeZoneId.isEmpty` instead in `Re…
ueshin Jan 11, 2017
183945c
Merge branch 'master' into issues/SPARK-18350
ueshin Jan 14, 2017
22a3b6e
Remove unused parameter.
ueshin Jan 16, 2017
30d51fa
Merge branch 'master' into issues/SPARK-18350
ueshin Jan 16, 2017
043ab52
Use Cast directly instead of dsl.
ueshin Jan 16, 2017
3ba5830
Merge branch 'master' into issues/SPARK-18350
ueshin Jan 22, 2017
9ab31f0
Revert unnecessary changes.
ueshin Jan 22, 2017
b954947
Use `@` binding to simplify pattern match.
ueshin Jan 22, 2017
dbb2604
Inline a `lazy val`.
ueshin Jan 22, 2017
186cd3e
Add some TODO comments for follow-up prs.
ueshin Jan 22, 2017
6631a69
Add a config document.
ueshin Jan 22, 2017
3610465
Use an overload version of `checkAnswer`.
ueshin Jan 22, 2017
c12e596
Fix CastSuite and add some comments to describe the tests.
ueshin Jan 22, 2017
8a04e80
Use None instead of null.
ueshin Jan 22, 2017
efe3aff
Add some comments to describe the tests.
ueshin Jan 22, 2017
cdbb266
Make TimeAdd/TimeSub/MonthsBetween TimeZoneAwareExpression.
ueshin Jan 22, 2017
328399a
Add comments to explain tests.
ueshin Jan 23, 2017
7352612
Modify a test.
ueshin Jan 23, 2017
b99cf79
Refine tests.
ueshin Jan 25, 2017
a85377f
Remove unnecessary new lines.
ueshin Jan 26, 2017
f0c911b
Add newDateFormat to DateTimeUtils and use it.
ueshin Jan 26, 2017
6fa1d6a
Parameterize some tests.
ueshin Jan 26, 2017
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
Add DateTimeUtils.threadLocalLocalTimeZone to partition-reltated Cast.
  • Loading branch information
ueshin committed Dec 16, 2016
commit f58f00df14a60afccf84c10c94c96d64bf6c4724
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.apache.spark.sql.catalyst.{FunctionIdentifier, InternalRow, TableIden
import org.apache.spark.sql.catalyst.expressions.{Attribute, Cast, Literal}
import org.apache.spark.sql.catalyst.plans.logical.{LeafNode, LogicalPlan, Statistics}
import org.apache.spark.sql.catalyst.util.quoteIdentifier
import org.apache.spark.sql.catalyst.util.DateTimeUtils
import org.apache.spark.sql.types.{StructField, StructType}


Expand Down Expand Up @@ -111,7 +112,8 @@ case class CatalogTablePartition(
*/
def toRow(partitionSchema: StructType): InternalRow = {
InternalRow.fromSeq(partitionSchema.map { field =>
Cast(Literal(spec(field.name)), field.dataType).eval()
Cast(Literal(spec(field.name)), field.dataType,
DateTimeUtils.threadLocalLocalTimeZone.get().getID).eval()
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ object DateTimeUtils {
}

// Java TimeZone has no mention of thread safety. Use thread local instance to be safe.
private val threadLocalLocalTimeZone = new ThreadLocal[TimeZone] {
val threadLocalLocalTimeZone = new ThreadLocal[TimeZone] {
override protected def initialValue: TimeZone = {
Calendar.getInstance.getTimeZone
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.aggregate._
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.catalyst.rules.Rule
import org.apache.spark.sql.catalyst.util.DateTimeUtils
import org.apache.spark.sql.execution.datasources.{HadoopFsRelation, LogicalRelation}
import org.apache.spark.sql.internal.SQLConf

Expand Down Expand Up @@ -104,7 +105,8 @@ case class OptimizeMetadataOnlyQuery(
val partAttrs = getPartitionAttrs(relation.catalogTable.partitionColumnNames, relation)
val partitionData = catalog.listPartitions(relation.catalogTable.identifier).map { p =>
InternalRow.fromSeq(partAttrs.map { attr =>
Cast(Literal(p.spec(attr.name)), attr.dataType).eval()
Cast(Literal(p.spec(attr.name)), attr.dataType,
DateTimeUtils.threadLocalLocalTimeZone.get().getID).eval()
})
}
LocalRelation(partAttrs, partitionData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.plans.physical.HashPartitioning
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
import org.apache.spark.sql.catalyst.util.DateTimeUtils
import org.apache.spark.sql.execution.{QueryExecution, SQLExecution, UnsafeKVExternalSorter}
import org.apache.spark.sql.types.{IntegerType, StringType, StructField, StructType}
import org.apache.spark.util.{SerializableConfiguration, Utils}
Expand Down Expand Up @@ -288,7 +289,7 @@ object FileFormatWriter extends Logging {
val escaped = ScalaUDF(
ExternalCatalogUtils.escapePathName _,
StringType,
Seq(Cast(c, StringType)),
Seq(Cast(c, StringType, DateTimeUtils.threadLocalLocalTimeZone.get().getID)),
Seq(StringType))
val str = If(IsNull(c), Literal(ExternalCatalogUtils.DEFAULT_PARTITION_NAME), escaped)
val partitionName = Literal(c.name + "=") :: str :: Nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.apache.spark.metrics.source.HiveCatalogMetrics
import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.catalyst.{expressions, InternalRow}
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.util.DateTimeUtils
import org.apache.spark.sql.types.{StringType, StructType}
import org.apache.spark.util.SerializableConfiguration

Expand Down Expand Up @@ -137,7 +138,8 @@ abstract class PartitioningAwareFileIndex(
InternalRow((0 until row.numFields).map { i =>
Cast(
Literal.create(row.getUTF8String(i), StringType),
userProvidedSchema.fields(i).dataType).eval()
userProvidedSchema.fields(i).dataType,
DateTimeUtils.threadLocalLocalTimeZone.get().getID).eval()
}: _*)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import org.apache.spark.internal.io.SparkHadoopWriterUtils
import org.apache.spark.mapred.SparkHadoopMapRedUtil
import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.util.DateTimeUtils
import org.apache.spark.sql.execution.UnsafeKVExternalSorter
import org.apache.spark.sql.hive.HiveShim.{ShimFileSinkDesc => FileSinkDesc}
import org.apache.spark.sql.types._
Expand Down Expand Up @@ -263,7 +264,9 @@ private[spark] class SparkHiveDynamicPartitionWriterContainer(
// Expressions that given a partition key build a string like: col1=val/col2=val/...
val partitionStringExpression = partitionOutput.zipWithIndex.flatMap { case (c, i) =>
val escaped =
ScalaUDF(fun, StringType, Seq(Cast(c, StringType)), Seq(StringType))
ScalaUDF(fun, StringType,
Seq(Cast(c, StringType, DateTimeUtils.threadLocalLocalTimeZone.get().getID)),
Seq(StringType))
val str = If(IsNull(c), Literal(defaultPartName), escaped)
val partitionName = Literal(dynamicPartColNames(i) + "=") :: str :: Nil
if (i == 0) partitionName else Literal(Path.SEPARATOR_CHAR.toString) :: partitionName
Expand Down