Skip to content

Commit 00fe81f

Browse files
committed
address lian cheng's comments
1 parent 0df6ea1 commit 00fe81f

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ case class Cast(child: Expression, dataType: DataType) extends UnaryExpression w
6262
case TimestampType =>
6363
buildCast[Timestamp](_, t => t.getTime() != 0 || t.getNanos() != 0)
6464
case DateType =>
65+
// Hive would return null when cast from date to boolean
6566
buildCast[Date](_, d => null)
6667
case LongType =>
6768
buildCast[Long](_, _ != 0)

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/types/dataTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ case object DateType extends NativeType {
256256
@transient private[sql] lazy val tag = ScalaReflectionLock.synchronized { typeTag[JvmType] }
257257

258258
private[sql] val ordering = new Ordering[JvmType] {
259-
def compare(x: Date, y: Date) = x.toString.compareTo(y.toString)
259+
def compare(x: Date, y: Date) = x.compareTo(y)
260260
}
261261
}
262262

sql/core/src/main/scala/org/apache/spark/sql/columnar/ColumnStats.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ private[sql] class DateColumnStats extends ColumnStats {
198198
override def gatherStats(row: Row, ordinal: Int) {
199199
if (!row.isNullAt(ordinal)) {
200200
val value = row(ordinal).asInstanceOf[Date]
201-
if (upper == null || value.toString.compareTo(upper.toString) > 0) upper = value
202-
if (lower == null || value.toString.compareTo(lower.toString) < 0) lower = value
201+
if (upper == null || value.compareTo(upper) > 0) upper = value
202+
if (lower == null || value.compareTo(lower) < 0) lower = value
203203
} else {
204204
nullCount += 1
205205
}

sql/core/src/main/scala/org/apache/spark/sql/columnar/ColumnType.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,15 @@ private[sql] object DATE extends NativeColumnType(DateType, 8, 8) {
341341
date
342342
}
343343

344-
override def append(v: Date, buffer: ByteBuffer) {
344+
override def append(v: Date, buffer: ByteBuffer): Unit = {
345345
buffer.putLong(v.getTime)
346346
}
347347

348348
override def getField(row: Row, ordinal: Int) = {
349349
row(ordinal).asInstanceOf[Date]
350350
}
351351

352-
override def setField(row: MutableRow, ordinal: Int, value: Date) {
352+
override def setField(row: MutableRow, ordinal: Int, value: Date): Unit = {
353353
row(ordinal) = value
354354
}
355355
}

0 commit comments

Comments
 (0)