Repository: spark
Updated Branches:
  refs/heads/master 84a6982b3 -> 5d9e33d9a


[SPARK-9495] prefix of DateType/TimestampType

cc rxin

Author: Davies Liu <dav...@databricks.com>

Closes #7856 from davies/sort_improve and squashes the following commits:

5fc81bd [Davies Liu] support DateType/TimestampType


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/5d9e33d9
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/5d9e33d9
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/5d9e33d9

Branch: refs/heads/master
Commit: 5d9e33d9a2633e45082ac395a64646364f22f4c4
Parents: 84a6982
Author: Davies Liu <dav...@databricks.com>
Authored: Sat Aug 1 18:22:46 2015 -0700
Committer: Reynold Xin <r...@databricks.com>
Committed: Sat Aug 1 18:22:46 2015 -0700

----------------------------------------------------------------------
 .../org/apache/spark/sql/catalyst/expressions/SortOrder.scala  | 2 ++
 .../scala/org/apache/spark/sql/execution/SortPrefixUtils.scala | 6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/5d9e33d9/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/SortOrder.scala
----------------------------------------------------------------------
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/SortOrder.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/SortOrder.scala
index 9fe877f..afecf88 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/SortOrder.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/SortOrder.scala
@@ -61,6 +61,8 @@ case class SortPrefix(child: SortOrder) extends 
UnaryExpression {
         (Long.MinValue, s"$input ? 1L : 0L")
       case _: IntegralType =>
         (Long.MinValue, s"(long) $input")
+      case DateType | TimestampType =>
+        (Long.MinValue, s"(long) $input")
       case FloatType | DoubleType =>
         (DoublePrefixComparator.computePrefix(Double.NegativeInfinity),
           s"$DoublePrefixCmp.computePrefix((double)$input)")

http://git-wip-us.apache.org/repos/asf/spark/blob/5d9e33d9/sql/core/src/main/scala/org/apache/spark/sql/execution/SortPrefixUtils.scala
----------------------------------------------------------------------
diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/SortPrefixUtils.scala 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/SortPrefixUtils.scala
index 17d4166..6766565 100644
--- 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/SortPrefixUtils.scala
+++ 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/SortPrefixUtils.scala
@@ -38,9 +38,11 @@ object SortPrefixUtils {
     sortOrder.dataType match {
       case StringType if sortOrder.isAscending => PrefixComparators.STRING
       case StringType if !sortOrder.isAscending => 
PrefixComparators.STRING_DESC
-      case BooleanType | ByteType | ShortType | IntegerType | LongType if 
sortOrder.isAscending =>
+      case BooleanType | ByteType | ShortType | IntegerType | LongType | 
DateType | TimestampType
+          if sortOrder.isAscending =>
         PrefixComparators.LONG
-      case BooleanType | ByteType | ShortType | IntegerType | LongType if 
!sortOrder.isAscending =>
+      case BooleanType | ByteType | ShortType | IntegerType | LongType | 
DateType | TimestampType
+        if !sortOrder.isAscending =>
         PrefixComparators.LONG_DESC
       case FloatType | DoubleType if sortOrder.isAscending => 
PrefixComparators.DOUBLE
       case FloatType | DoubleType if !sortOrder.isAscending => 
PrefixComparators.DOUBLE_DESC


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to