aboutsummaryrefslogtreecommitdiff
path: root/sql/catalyst/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'sql/catalyst/src/main')
-rw-r--r--sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala9
1 files changed, 2 insertions, 7 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
index b1e89b5de8..a12fba047b 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
@@ -52,7 +52,8 @@ object Cast {
case (DateType, TimestampType) => true
case (_: NumericType, TimestampType) => true
- case (_, DateType) => true
+ case (StringType, DateType) => true
+ case (TimestampType, DateType) => true
case (StringType, CalendarIntervalType) => true
@@ -228,18 +229,12 @@ case class Cast(child: Expression, dataType: DataType) extends UnaryExpression w
// throw valid precision more than seconds, according to Hive.
// Timestamp.nanos is in 0 to 999,999,999, no more than a second.
buildCast[Long](_, t => DateTimeUtils.millisToDays(t / 1000L))
- // Hive throws this exception as a Semantic Exception
- // It is never possible to compare result when hive return with exception,
- // so we can return null
- // NULL is more reasonable here, since the query itself obeys the grammar.
- case _ => _ => null
}
// IntervalConverter
private[this] def castToInterval(from: DataType): Any => Any = from match {
case StringType =>
buildCast[UTF8String](_, s => CalendarInterval.fromString(s.toString))
- case _ => _ => null
}
// LongConverter