aboutsummaryrefslogtreecommitdiff
path: root/sql/hive/src/test
diff options
context:
space:
mode:
authorWenchen Fan <wenchen@databricks.com>2016-07-25 22:02:00 +0800
committerCheng Lian <lian@databricks.com>2016-07-25 22:02:00 +0800
commitd27d362ebae0c4a5cc6c99f13ef20049214dd4f9 (patch)
tree0f214921fc8ac1aff74f0c8e4f171adb724c43fc /sql/hive/src/test
parent7ffd99ec5f267730734431097cbb700ad074bebe (diff)
downloadspark-d27d362ebae0c4a5cc6c99f13ef20049214dd4f9.tar.gz
spark-d27d362ebae0c4a5cc6c99f13ef20049214dd4f9.tar.bz2
spark-d27d362ebae0c4a5cc6c99f13ef20049214dd4f9.zip
[SPARK-16660][SQL] CreateViewCommand should not take CatalogTable
## What changes were proposed in this pull request? `CreateViewCommand` only needs some information of a `CatalogTable`, but not all of them. We have some tricks(e.g. we need to check the table type is `VIEW`, we need to make `CatalogColumn.dataType` nullable) to allow it to take a `CatalogTable`. This PR cleans it up and only pass in necessary information to `CreateViewCommand`. ## How was this patch tested? existing tests. Author: Wenchen Fan <wenchen@databricks.com> Closes #14297 from cloud-fan/minor2.
Diffstat (limited to 'sql/hive/src/test')
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveDDLCommandSuite.scala46
1 files changed, 14 insertions, 32 deletions
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveDDLCommandSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveDDLCommandSuite.scala
index 9d99d960ac..a708434f5e 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveDDLCommandSuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveDDLCommandSuite.scala
@@ -37,7 +37,6 @@ class HiveDDLCommandSuite extends PlanTest {
parser.parsePlan(sql).collect {
case c: CreateTableCommand => (c.table, c.ifNotExists)
case c: CreateHiveTableAsSelectLogicalPlan => (c.tableDesc, c.allowExisting)
- case c: CreateViewCommand => (c.tableDesc, c.allowExisting)
}.head
}
@@ -470,47 +469,30 @@ class HiveDDLCommandSuite extends PlanTest {
test("create view -- basic") {
val v1 = "CREATE VIEW view1 AS SELECT * FROM tab1"
- val (desc, exists) = extractTableDesc(v1)
- assert(!exists)
- assert(desc.identifier.database.isEmpty)
- assert(desc.identifier.table == "view1")
- assert(desc.tableType == CatalogTableType.VIEW)
- assert(desc.storage.locationUri.isEmpty)
- assert(desc.schema == Seq.empty[CatalogColumn])
- assert(desc.viewText == Option("SELECT * FROM tab1"))
- assert(desc.viewOriginalText == Option("SELECT * FROM tab1"))
- assert(desc.storage.properties == Map())
- assert(desc.storage.inputFormat.isEmpty)
- assert(desc.storage.outputFormat.isEmpty)
- assert(desc.storage.serde.isEmpty)
- assert(desc.properties == Map())
+ val command = parser.parsePlan(v1).asInstanceOf[CreateViewCommand]
+ assert(!command.allowExisting)
+ assert(command.name.database.isEmpty)
+ assert(command.name.table == "view1")
+ assert(command.originalText == Some("SELECT * FROM tab1"))
+ assert(command.userSpecifiedColumns.isEmpty)
}
test("create view - full") {
val v1 =
"""
|CREATE OR REPLACE VIEW view1
- |(col1, col3)
+ |(col1, col3 COMMENT 'hello')
|COMMENT 'BLABLA'
|TBLPROPERTIES('prop1Key'="prop1Val")
|AS SELECT * FROM tab1
""".stripMargin
- val (desc, exists) = extractTableDesc(v1)
- assert(desc.identifier.database.isEmpty)
- assert(desc.identifier.table == "view1")
- assert(desc.tableType == CatalogTableType.VIEW)
- assert(desc.storage.locationUri.isEmpty)
- assert(desc.schema ==
- CatalogColumn("col1", null, nullable = true, None) ::
- CatalogColumn("col3", null, nullable = true, None) :: Nil)
- assert(desc.viewText == Option("SELECT * FROM tab1"))
- assert(desc.viewOriginalText == Option("SELECT * FROM tab1"))
- assert(desc.storage.properties == Map())
- assert(desc.storage.inputFormat.isEmpty)
- assert(desc.storage.outputFormat.isEmpty)
- assert(desc.storage.serde.isEmpty)
- assert(desc.properties == Map("prop1Key" -> "prop1Val"))
- assert(desc.comment == Option("BLABLA"))
+ val command = parser.parsePlan(v1).asInstanceOf[CreateViewCommand]
+ assert(command.name.database.isEmpty)
+ assert(command.name.table == "view1")
+ assert(command.userSpecifiedColumns == Seq("col1" -> None, "col3" -> Some("hello")))
+ assert(command.originalText == Some("SELECT * FROM tab1"))
+ assert(command.properties == Map("prop1Key" -> "prop1Val"))
+ assert(command.comment == Some("BLABLA"))
}
test("create view -- partitioned view") {