Skip to content

Commit

Permalink
address lian cheng's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-wang committed Oct 10, 2014
1 parent 0df6ea1 commit 00fe81f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ case class Cast(child: Expression, dataType: DataType) extends UnaryExpression w
case TimestampType =>
buildCast[Timestamp](_, t => t.getTime() != 0 || t.getNanos() != 0)
case DateType =>
// Hive would return null when cast from date to boolean
buildCast[Date](_, d => null)
case LongType =>
buildCast[Long](_, _ != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ case object DateType extends NativeType {
@transient private[sql] lazy val tag = ScalaReflectionLock.synchronized { typeTag[JvmType] }

private[sql] val ordering = new Ordering[JvmType] {
def compare(x: Date, y: Date) = x.toString.compareTo(y.toString)
def compare(x: Date, y: Date) = x.compareTo(y)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ private[sql] class DateColumnStats extends ColumnStats {
override def gatherStats(row: Row, ordinal: Int) {
if (!row.isNullAt(ordinal)) {
val value = row(ordinal).asInstanceOf[Date]
if (upper == null || value.toString.compareTo(upper.toString) > 0) upper = value
if (lower == null || value.toString.compareTo(lower.toString) < 0) lower = value
if (upper == null || value.compareTo(upper) > 0) upper = value
if (lower == null || value.compareTo(lower) < 0) lower = value
} else {
nullCount += 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,15 @@ private[sql] object DATE extends NativeColumnType(DateType, 8, 8) {
date
}

override def append(v: Date, buffer: ByteBuffer) {
override def append(v: Date, buffer: ByteBuffer): Unit = {
buffer.putLong(v.getTime)
}

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

override def setField(row: MutableRow, ordinal: Int, value: Date) {
override def setField(row: MutableRow, ordinal: Int, value: Date): Unit = {
row(ordinal) = value
}
}
Expand Down

0 comments on commit 00fe81f

Please sign in to comment.