Skip to content
Snippets Groups Projects
Commit 5d9e33d9 authored by Davies Liu's avatar Davies Liu Committed by Reynold Xin
Browse files

[SPARK-9495] prefix of DateType/TimestampType

cc rxin

Author: Davies Liu <davies@databricks.com>

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

5fc81bd [Davies Liu] support DateType/TimestampType
parent 84a6982b
No related branches found
No related tags found
No related merge requests found
......@@ -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)")
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment