Skip to content

Commit

Permalink
[SPARK-7229] [SQL] SpecificMutableRow should take integer type as int…
Browse files Browse the repository at this point in the history
…ernal representation for Date

Author: Cheng Hao <hao.cheng@intel.com>

Closes apache#5772 from chenghao-intel/specific_row and squashes the following commits:

2cd064d [Cheng Hao] scala style issue
60347a2 [Cheng Hao] SpecificMutableRow should take integer type as internal representation for DateType
  • Loading branch information
chenghao-intel authored and nemccarthy committed Jun 19, 2015
1 parent 4ab3f32 commit 2224497
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ final class SpecificMutableRow(val values: Array[MutableValue]) extends MutableR
case DoubleType => new MutableDouble
case BooleanType => new MutableBoolean
case LongType => new MutableLong
case DateType => new MutableInt // We use INT for DATE internally
case _ => new MutableAny
}.toArray)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,15 @@ class JDBCSuite extends FunSuite with BeforeAndAfter {
assert(cachedRows(0).getAs[java.sql.Date](1) === java.sql.Date.valueOf("1996-01-01"))
}

test("test DATE types in cache") {
val rows = TestSQLContext.jdbc(urlWithUserAndPass, "TEST.TIMETYPES").collect()
TestSQLContext
.jdbc(urlWithUserAndPass, "TEST.TIMETYPES").cache().registerTempTable("mycached_date")
val cachedRows = sql("select * from mycached_date").collect()
assert(rows(0).getAs[java.sql.Date](1) === java.sql.Date.valueOf("1996-01-01"))
assert(cachedRows(0).getAs[java.sql.Date](1) === java.sql.Date.valueOf("1996-01-01"))
}

test("H2 floating-point types") {
val rows = sql("SELECT * FROM flttypes").collect()
assert(rows(0).getDouble(0) === 1.00000000000000022) // Yes, I meant ==.
Expand Down

0 comments on commit 2224497

Please sign in to comment.