aboutsummaryrefslogtreecommitdiff
path: root/sql/hive/src
diff options
context:
space:
mode:
authorWenchen Fan <wenchen@databricks.com>2016-07-26 18:46:12 +0800
committerCheng Lian <lian@databricks.com>2016-07-26 18:46:12 +0800
commita2abb583caaec9a2cecd5d65b05d172fc096c125 (patch)
treeedaf8913f4f586a85be22e728fc41bb7bbb8066f /sql/hive/src
parent4c9695598ee00f68aff4eb32d4629edf6facb29f (diff)
downloadspark-a2abb583caaec9a2cecd5d65b05d172fc096c125.tar.gz
spark-a2abb583caaec9a2cecd5d65b05d172fc096c125.tar.bz2
spark-a2abb583caaec9a2cecd5d65b05d172fc096c125.zip
[SPARK-16663][SQL] desc table should be consistent between data source and hive serde tables
## What changes were proposed in this pull request? Currently there are 2 inconsistence: 1. for data source table, we only print partition names, for hive table, we also print partition schema. After this PR, we will always print schema 2. if column doesn't have comment, data source table will print empty string, hive table will print null. After this PR, we will always print null ## How was this patch tested? new test in `HiveDDLSuite` Author: Wenchen Fan <wenchen@databricks.com> Closes #14302 from cloud-fan/minor3.
Diffstat (limited to 'sql/hive/src')
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala2
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala30
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala4
3 files changed, 26 insertions, 10 deletions
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala
index 22f8c0f19c..111fb8b348 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala
@@ -748,7 +748,7 @@ class MetastoreDataSourcesSuite extends QueryTest with SQLTestUtils with TestHiv
assert(schema === actualSchema)
// Checks the DESCRIBE output.
- checkAnswer(sql("DESCRIBE spark6655"), Row("int", "int", "") :: Nil)
+ checkAnswer(sql("DESCRIBE spark6655"), Row("int", "int", null) :: Nil)
}
}
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
index fb5c9948a5..d15e11a7ff 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
@@ -431,6 +431,22 @@ class HiveDDLSuite
}
}
+ test("desc table for Hive table - partitioned table") {
+ withTable("tbl") {
+ sql("CREATE TABLE tbl(a int) PARTITIONED BY (b int)")
+
+ assert(sql("DESC tbl").collect().containsSlice(
+ Seq(
+ Row("a", "int", null),
+ Row("b", "int", null),
+ Row("# Partition Information", "", ""),
+ Row("# col_name", "data_type", "comment"),
+ Row("b", "int", null)
+ )
+ ))
+ }
+ }
+
test("desc table for data source table using Hive Metastore") {
assume(spark.sparkContext.conf.get(CATALOG_IMPLEMENTATION) == "hive")
val tabName = "tab1"
@@ -621,7 +637,7 @@ class HiveDDLSuite
val desc = sql("DESC FORMATTED t1").collect().toSeq
- assert(desc.contains(Row("id", "bigint", "")))
+ assert(desc.contains(Row("id", "bigint", null)))
}
}
}
@@ -638,13 +654,13 @@ class HiveDDLSuite
assert(formattedDesc.containsSlice(
Seq(
- Row("a", "bigint", ""),
- Row("b", "bigint", ""),
- Row("c", "bigint", ""),
- Row("d", "bigint", ""),
+ Row("a", "bigint", null),
+ Row("b", "bigint", null),
+ Row("c", "bigint", null),
+ Row("d", "bigint", null),
Row("# Partition Information", "", ""),
- Row("# col_name", "", ""),
- Row("d", "", ""),
+ Row("# col_name", "data_type", "comment"),
+ Row("d", "bigint", null),
Row("", "", ""),
Row("# Detailed Table Information", "", ""),
Row("Database:", "default", "")
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
index f8c55ec456..31283b9fd6 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
@@ -834,8 +834,8 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter {
assertResult(
Array(
- Row("a", "int", ""),
- Row("b", "string", ""))
+ Row("a", "int", null),
+ Row("b", "string", null))
) {
sql("DESCRIBE test_describe_commands2")
.select('col_name, 'data_type, 'comment)