Skip to content

Commit

Permalink
[Spark-2137][SQL] Timestamp UDFs broken
Browse files Browse the repository at this point in the history
https://issues.apache.org/jira/browse/SPARK-2137

Author: Yin Huai <huai@cse.ohio-state.edu>

Closes #1081 from yhuai/SPARK-2137 and squashes the following commits:

c04f910 [Yin Huai] Merge remote-tracking branch 'upstream/master' into SPARK-2137
205f17b [Yin Huai] Make Hive UDF wrapper support Timestamp.
  • Loading branch information
yhuai authored and rxin committed Jun 14, 2014
1 parent edb1f0e commit 8919685
Show file tree
Hide file tree
Showing 19 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class HiveContext(sc: SparkContext) extends SQLContext(sc) {

protected val primitiveTypes =
Seq(StringType, IntegerType, LongType, DoubleType, FloatType, BooleanType, ByteType,
ShortType, DecimalType)
ShortType, DecimalType, TimestampType)

protected def toHiveString(a: (Any, DataType)): String = a match {
case (struct: Row, StructType(fields)) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ private[hive] case class HiveSimpleUdf(name: String, children: Seq[Expression])
val primitiveClasses = Seq(
Integer.TYPE, classOf[java.lang.Integer], classOf[java.lang.String], java.lang.Double.TYPE,
classOf[java.lang.Double], java.lang.Long.TYPE, classOf[java.lang.Long],
classOf[HiveDecimal], java.lang.Byte.TYPE, classOf[java.lang.Byte]
classOf[HiveDecimal], java.lang.Byte.TYPE, classOf[java.lang.Byte],
classOf[java.sql.Timestamp]
)
val matchingConstructor = argClass.getConstructors.find { c =>
c.getParameterTypes.size == 1 && primitiveClasses.contains(c.getParameterTypes.head)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2011-05-06 07:08:09.1234567 2011-05-06 02:08:09.1234567
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2011-05-06 07:08:09.1234567 2011-05-06 02:08:09.1234567 2011-05-06 07:08:09.1234567 2011-05-06 02:08:09.1234567
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2011-05-06 07:08:09.1234567 2011-05-06 12:08:09.1234567
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2011-05-06 07:08:09.1234567 2011-05-06 12:08:09.1234567 2011-05-06 07:08:09.1234567 2011-05-06 12:08:09.1234567
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1304690889 2011 5 6 6 18 7 8 9 2011-05-06
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2011-05-11 2011-04-26
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 3333 -3333
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2011-05-06 02:08:09.1234567
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2011-05-06 12:08:09.1234567
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1304690889 2011 5 6 6 18 7 8 9 2011-05-06
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2011-05-11 2011-04-26
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 3333 -3333
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2011-05-06 02:08:09.1234567
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2011-05-06 12:08:09.1234567

0 comments on commit 8919685

Please sign in to comment.