Uh oh!
There was an error while loading. Please reload this page.
[SPARK-20412] Throw ParseException from visitNonOptionalPartitionSpec instead of returning null values. - #17707
[SPARK-20412] Throw ParseException from visitNonOptionalPartitionSpec instead of returning null values.#17707juliuszsompolski wants to merge 4 commits into
Conversation
juliuszsompolski
commented
Apr 20, 2017
cc @cloud-fan |
hvanhovell
commented
Apr 20, 2017
ok to test |
hvanhovell
commented
Apr 20, 2017
Could you add a unit test to the DDLCommandSuite? |
SparkQA
commented
Apr 20, 2017
Test build #75994 has finished for PR 17707 at commit
|
SparkQA
commented
Apr 20, 2017
Test build #75997 has finished for PR 17707 at commit
|
cloud-fan
commented
Apr 21, 2017
looks like we need to fix a test |
| protected def visitNonOptionalPartitionSpec( | ||
| ctx: PartitionSpecContext): Map[String, String] = withOrigin(ctx) { | ||
| visitPartitionSpec(ctx).mapValues(_.orNull).map(identity) | ||
| ctx: PartitionSpecContext): Map[String, String] = withOrigin(ctx) { |
There was a problem hiding this comment.
Nit: Indentation issues. Need to add extra two spaces
| visitPartitionSpec(ctx).mapValues(_.orNull).map(identity) | ||
| ctx: PartitionSpecContext): Map[String, String] = withOrigin(ctx) { | ||
| visitPartitionSpec(ctx).map { | ||
| case (key, None) => throw new ParseException(s"Found empty key '$key'.", ctx) |
There was a problem hiding this comment.
How about Found an empty partition key '$key'?
SparkQA
commented
Apr 21, 2017
Test build #76029 has finished for PR 17707 at commit
|
| tableIdent, | ||
| None, | ||
| Some(Map("columns" -> "foo,bar", "field.delim" -> ",")), | ||
| Some(Map("test" -> null, "dt" -> "2008-08-08", "country" -> "us"))) |
There was a problem hiding this comment.
BTW: In AlterTableSerDePropertiesCommand that null would have caused a NullPointerExeception later, so not having this as null, but checked as ParseException is also a valid change here.
cloud-fan
commented
Apr 21, 2017
thanks, merging to master/2.2! |
… instead of returning null values. ## What changes were proposed in this pull request? If a partitionSpec is supposed to not contain optional values, a ParseException should be thrown, and not nulls returned. The nulls can later cause NullPointerExceptions in places not expecting them. ## How was this patch tested? A query like "SHOW PARTITIONS tbl PARTITION(col1='val1', col2)" used to throw a NullPointerException. Now it throws a ParseException. Author: Juliusz Sompolski <julek@databricks.com> Closes#17707 from juliuszsompolski/SPARK-20412. (cherry picked from commit c9e6035) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
… instead of returning null values. ## What changes were proposed in this pull request? If a partitionSpec is supposed to not contain optional values, a ParseException should be thrown, and not nulls returned. The nulls can later cause NullPointerExceptions in places not expecting them. ## How was this patch tested? A query like "SHOW PARTITIONS tbl PARTITION(col1='val1', col2)" used to throw a NullPointerException. Now it throws a ParseException. Author: Juliusz Sompolski <julek@databricks.com> Closesapache#17707 from juliuszsompolski/SPARK-20412.
What changes were proposed in this pull request?
If a partitionSpec is supposed to not contain optional values, a ParseException should be thrown, and not nulls returned.
The nulls can later cause NullPointerExceptions in places not expecting them.
How was this patch tested?
A query like "SHOW PARTITIONS tbl PARTITION(col1='val1', col2)" used to throw a NullPointerException.
Now it throws a ParseException.