Skip to content

Commit

Permalink
add more concise unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
chenghao-intel committed Dec 17, 2014
1 parent 853de51 commit e7a72e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,15 @@ class JsonSuite extends QueryTest {
StructField("Charset", StringType, true) ::
StructField("Host", StringType, true) :: Nil)
, true) ::
StructField("ip", StringType, true) :: Nil)
StructField("ip", StringType, true) ::
StructField("nullstr", StringType, true):: Nil)

assert(expectedSchema === jsonSchemaRDD.schema)
jsonSchemaRDD.registerTempTable("jsonTable")

checkAnswer(
sql("select headers.Host from jsonTable"),
Seq(Row("1.abc.com"), Row(null), Row(null))
sql("select nullstr, headers.Host from jsonTable"),
Seq(Row("", "1.abc.com"), Row("", null), Row("", null), Row(null, null))
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ object TestJsonData {

val jsonNullStruct =
TestSQLContext.sparkContext.parallelize(
"""{"ip":"27.31.100.29","headers":{"Host":"1.abc.com","Charset":"UTF-8"}}""" ::
"""{"ip":"27.31.100.29","headers":{}}""" ::
"""{"ip":"27.31.100.29","headers":""}""" :: Nil)
"""{"nullstr":"","ip":"27.31.100.29","headers":{"Host":"1.abc.com","Charset":"UTF-8"}}""" ::
"""{"nullstr":"","ip":"27.31.100.29","headers":{}}""" ::
"""{"nullstr":"","ip":"27.31.100.29","headers":""}""" ::
"""{"nullstr":null,"ip":"27.31.100.29","headers":null}""" :: Nil)

val complexFieldValueTypeConflict =
TestSQLContext.sparkContext.parallelize(
Expand Down

0 comments on commit e7a72e9

Please sign in to comment.