Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/13079#discussion_r63414957
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/ShowCreateTableSuite.scala ---
@@ -116,24 +116,143 @@ class ShowCreateTableSuite extends QueryTest with
SQLTestUtils with TestHiveSing
.bucketBy(2, "c", "d")
.saveAsTable("ddl_test5")
- checkCreateTable(TableIdentifier("ddl_test5", Some("default")))
+ checkCreateTable("ddl_test5")
+ }
+ }
+
+ test("simple hive table") {
+ withTable("t1") {
+ sql(
+ s"""CREATE TABLE t1 (
+ | c1 INT COMMENT 'bla',
+ | c2 STRING
+ |)
+ |TBLPROPERTIES (
+ | 'prop1' = 'value1',
+ | 'prop2' = 'value2'
+ |)
+ """.stripMargin
+ )
+
+ checkCreateTable("t1")
+ }
+ }
+
+ test("simple external hive table") {
+ withTempDir { dir =>
+ withTable("t1") {
+ sql(
+ s"""CREATE TABLE t1 (
+ | c1 INT COMMENT 'bla',
+ | c2 STRING
+ |)
+ |LOCATION '$dir'
+ |TBLPROPERTIES (
+ | 'prop1' = 'value1',
+ | 'prop2' = 'value2'
+ |)
+ """.stripMargin
+ )
+
+ checkCreateTable("t1")
+ }
+ }
+ }
+
+ test("partitioned hive table") {
+ withTable("t1") {
+ sql(
+ s"""CREATE TABLE t1 (
+ | c1 INT COMMENT 'bla',
+ | c2 STRING
+ |)
+ |COMMENT 'bla'
+ |PARTITIONED BY (
+ | p1 BIGINT COMMENT 'bla',
+ | p2 STRING
+ |)
+ """.stripMargin
+ )
+
+ checkCreateTable("t1")
+ }
+ }
+
+ test("hive table with explicit storage info") {
+ withTable("t1") {
+ sql(
+ s"""CREATE TABLE t1 (
+ | c1 INT COMMENT 'bla',
+ | c2 STRING
+ |)
+ |ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
+ |COLLECTION ITEMS TERMINATED BY '@'
+ |MAP KEYS TERMINATED BY '#'
+ |NULL DEFINED AS 'NaN'
+ |STORED AS PARQUET
+ """.stripMargin
+ )
+
+ checkCreateTable("t1")
+ }
+ }
+
+ test("hive table with serde info") {
+ withTable("t1") {
+ sql(
+ s"""CREATE TABLE t1 (
+ | c1 INT COMMENT 'bla',
+ | c2 STRING
+ |)
+ |ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
+ |WITH SERDEPROPERTIES (
+ | 'mapkey.delim' = ',',
+ | 'field.delim' = ','
+ |)
+ |STORED AS
+ | INPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
+ | OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
+ """.stripMargin
+ )
+
+ checkCreateTable("t1")
+ }
+ }
+
+ test("hive view") {
+ withView("v1") {
+ sql("CREATE VIEW v1 AS SELECT 1 AS a")
+ checkCreateView("v1")
+ }
+ }
+
+ test("hive view with output columns") {
+ withView("v1") {
+ sql("CREATE VIEW v1 (b) AS SELECT 1 AS a")
+ checkCreateView("v1")
--- End diff --
let's also have a test for `STORED AS`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]