Skip to content

Commit

Permalink
SPARKC-275: Make OptionConverter handle Nones as well as nulls
Browse files Browse the repository at this point in the history
  • Loading branch information
jotsif authored and pkolaczk committed Dec 1, 2015
1 parent 59f0f51 commit 8def8b7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Fix merge strategy for netty.io.properties (SPARKC-249)
* Upgrade integration tests to use Cassandra 2.1.9 and upgrade Java Driver
to 2.1.7.1, Spark to 1.4.1 (SPARKC-248)
* Make OptionConverter handle Nones as well as nulls (SPARKC-275)

1.4.0
* Fixed broken integration tests (SPARKC-247):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ object TypeConverter {

def convertPF = {
case null => None
case None => None
case other => Some(c.convert(other))
}
}
Expand Down Expand Up @@ -854,4 +855,4 @@ object TypeConverter {
converters = c +: converters
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ class CassandraRowTest extends FunSuite with ShouldMatchers {
assertEquals(1, row.size)
}

test("NoneAccessTest") {
val row = new CassandraRow(Array("value"), Array(None))
assertEquals(None, row.getStringOption(0))
assertEquals(None, row.getStringOption("value"))
assertEquals(1, row.size)
}


test("nullToStringTest") {
val row = new CassandraRow(Array("value"), Array(null))
assertEquals("CassandraRow{value: null}", row.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ class TypeConverterTest {
def testOption() {
val c = TypeConverter.forType[Option[String]]
assertEquals(None, c.convert(null))
assertEquals(None, c.convert(None))
assertEquals(Some("not-null"), c.convert("not-null"))
}

Expand Down

0 comments on commit 8def8b7

Please sign in to comment.