Skip to content

Commit

Permalink
[SPARK-4676] [SQL] JavaSchemaRDD.schema may throw NullType MatchError…
Browse files Browse the repository at this point in the history
… if sql has null
  • Loading branch information
YanTangZhai committed Dec 2, 2014
1 parent 4b4bb34 commit e052dff
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,21 @@ class JavaSQLSuite extends FunSuite {
javaSqlCtx.sql("SELECT * FROM people").collect()
}

test("schema with null from JavaBeans") {
val person = new PersonBean
person.setName("Michael")
person.setAge(29)

val rdd = javaCtx.parallelize(person :: Nil)
val schemaRDD = javaSqlCtx.applySchema(rdd, classOf[PersonBean])

schemaRDD.registerTempTable("people")
val nullRDD = javaSqlCtx.sql("SELECT null FROM people")
val structFields = nullRDD.schema.getFields()
assert(structFields.size == 1)
assert(structFields(0).getDataType().isInstanceOf[NullType])
assert(nullRDD.collect.head.row === Seq(null))
}
test("schema with null from JavaBeans") {
val person = new PersonBean
person.setName("Michael")
person.setAge(29)

val rdd = javaCtx.parallelize(person :: Nil)
val schemaRDD = javaSqlCtx.applySchema(rdd, classOf[PersonBean])

schemaRDD.registerTempTable("people")
val nullRDD = javaSqlCtx.sql("SELECT null FROM people")
val structFields = nullRDD.schema.getFields()
assert(structFields.size == 1)
assert(structFields(0).getDataType().isInstanceOf[NullType])
assert(nullRDD.collect.head.row === Seq(null))
}

test("all types in JavaBeans") {
val bean = new AllTypesBean
Expand Down

0 comments on commit e052dff

Please sign in to comment.