Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added unit test that mixes constant field name and non constant one f…
…ield name
  • Loading branch information
jmchung committed Aug 15, 2017
commit 0078445575064a3eec455bcec62fbed0c6dd2001
Original file line number Diff line number Diff line change
Expand Up @@ -2042,5 +2042,17 @@ class JsonSuite extends QueryTest with SharedSQLContext with TestJsonData {
|, cast(NULL AS STRING), 'b'
|, cast(NULL AS STRING), 'a')
""".stripMargin), Row(null, "2", null, "1"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmchung Can we also add the test we discussed in slack which mixes constant field name and non constant one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viirya Done, the added test case contains column name, constant field name, and null field name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: move Row(null, "2", null, "1")) to the next line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thanks


// mixes constant field name and non constant one
withTempView("jsonTable") {
Seq(("""{"a": 1, "b": 2}""", "a", "b"))
.toDF("jsonField", "a", "b")
.createOrReplaceTempView("jsonTable")

checkAnswer(
sql("""SELECT json_tuple(jsonField, b, cast(NULL AS STRING), 'a') FROM jsonTable"""),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: """ -> "

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will move L2053 to json-functions.sql

Row("2", null, "1")
)
}
}
}