diff options
author | gatorsmile <gatorsmile@gmail.com> | 2016-11-27 19:43:24 -0800 |
---|---|---|
committer | gatorsmile <gatorsmile@gmail.com> | 2016-11-27 19:43:24 -0800 |
commit | 07f32c2283e26e86474ba8c9b50125831009a1ea (patch) | |
tree | 65ecc502e95b2eacc6ad8b170a62c0f2fd585c9e /sql/hive/src/test | |
parent | 9c03c564605783d8e94f6795432bb59c33933e52 (diff) | |
download | spark-07f32c2283e26e86474ba8c9b50125831009a1ea.tar.gz spark-07f32c2283e26e86474ba8c9b50125831009a1ea.tar.bz2 spark-07f32c2283e26e86474ba8c9b50125831009a1ea.zip |
[SPARK-18594][SQL] Name Validation of Databases/Tables
### What changes were proposed in this pull request?
Currently, the name validation checks are limited to table creation. It is enfored by Analyzer rule: `PreWriteCheck`.
However, table renaming and database creation have the same issues. It makes more sense to do the checks in `SessionCatalog`. This PR is to add it into `SessionCatalog`.
### How was this patch tested?
Added test cases
Author: gatorsmile <gatorsmile@gmail.com>
Closes #16018 from gatorsmile/nameValidate.
Diffstat (limited to 'sql/hive/src/test')
-rw-r--r-- | sql/hive/src/test/scala/org/apache/spark/sql/hive/MultiDatabaseSuite.scala | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/MultiDatabaseSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/MultiDatabaseSuite.scala index 9f4401ae22..7322465109 100644 --- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/MultiDatabaseSuite.scala +++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/MultiDatabaseSuite.scala @@ -269,17 +269,17 @@ class MultiDatabaseSuite extends QueryTest with SQLTestUtils with TestHiveSingle val message = intercept[AnalysisException] { df.write.format("parquet").saveAsTable("`d:b`.`t:a`") }.getMessage - assert(message.contains("is not a valid name for metastore")) + assert(message.contains("Database 'd:b' not found")) } { val message = intercept[AnalysisException] { df.write.format("parquet").saveAsTable("`d:b`.`table`") }.getMessage - assert(message.contains("is not a valid name for metastore")) + assert(message.contains("Database 'd:b' not found")) } - withTempPath { dir => + withTempDir { dir => val path = dir.getCanonicalPath { @@ -293,7 +293,8 @@ class MultiDatabaseSuite extends QueryTest with SQLTestUtils with TestHiveSingle |) """.stripMargin) }.getMessage - assert(message.contains("is not a valid name for metastore")) + assert(message.contains("`t:a` is not a valid name for tables/databases. " + + "Valid names only contain alphabet characters, numbers and _.")) } { @@ -307,7 +308,7 @@ class MultiDatabaseSuite extends QueryTest with SQLTestUtils with TestHiveSingle |) """.stripMargin) }.getMessage - assert(message.contains("is not a valid name for metastore")) + assert(message.contains("Database 'd:b' not found")) } } } |