Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
juliuszsompolski committed Apr 20, 2017
1 parent 59ba235 commit ca8ac7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ class AstBuilder extends SqlBaseBaseVisitor[AnyRef] with Logging {
* Create a partition specification map without optional values.
*/
protected def visitNonOptionalPartitionSpec(
ctx: PartitionSpecContext): Map[String, String] = withOrigin(ctx) {
visitPartitionSpec(ctx).map(_ match {
case (key, value) =>
(key, value.getOrElse(throw new ParseException(s"Found empty key '$key'.", ctx)))
})
ctx: PartitionSpecContext): Map[String, String] = withOrigin(ctx) {
visitPartitionSpec(ctx).map {
case (key, None) => throw new ParseException(s"Found empty key '$key'.", ctx)
case (key, Some(value)) => key -> value
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,14 @@ class DDLCommandSuite extends PlanTest {
assert(e.contains("Found duplicate keys 'a'"))
}

test("empty values in non-optional partition specs") {
val e = intercept[ParseException] {
parser.parsePlan(
"SHOW PARTITIONS dbx.tab1 PARTITION (a='1', b)")
}.getMessage
assert(e.contains("Found empty key 'b'"))
}

test("drop table") {
val tableName1 = "db.tab"
val tableName2 = "tab"
Expand Down

0 comments on commit ca8ac7e

Please sign in to comment.