Skip to content

Commit 112a0b6

Browse files
committed
add test case
1 parent 187c7d8 commit 112a0b6

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ class SQLQuerySuite extends QueryTest {
6969
"""CREATE TABLE IF NOT EXISTS ctas4 AS
7070
| SELECT key, value FROM src ORDER BY key, value""".stripMargin).collect()
7171

72+
sql(
73+
"""CREATE TABLE ctas5
74+
| ROW FORMAT SERDE 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
75+
| STORED AS
76+
| INPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
77+
| OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
78+
| AS
79+
| SELECT key, value
80+
| FROM src
81+
| ORDER BY key, value""".stripMargin).collect
82+
7283
checkAnswer(
7384
sql("SELECT k, value FROM ctas1 ORDER BY k, value"),
7485
sql("SELECT key, value FROM src ORDER BY key, value").collect().toSeq)
@@ -95,6 +106,13 @@ class SQLQuerySuite extends QueryTest {
95106
sql("SELECT key, value FROM ctas4 ORDER BY key, value"),
96107
sql("SELECT key, value FROM ctas4 LIMIT 1").collect().toSeq)
97108

109+
// use the Hive SerDe for parquet tables
110+
sql("set spark.sql.hive.convertMetastoreParquet = false")
111+
checkAnswer(
112+
sql("SELECT key, value FROM ctas5 ORDER BY key, value"),
113+
sql("SELECT key, value FROM src ORDER BY key, value").collect().toSeq)
114+
sql("set spark.sql.hive.convertMetastoreParquet = true")
115+
98116
checkExistence(sql("DESC EXTENDED ctas2"), true,
99117
"name:key", "type:string", "name:value", "ctas2",
100118
"org.apache.hadoop.hive.ql.io.RCFileInputFormat",
@@ -141,7 +159,7 @@ class SQLQuerySuite extends QueryTest {
141159
test("test CTAS") {
142160
checkAnswer(sql("CREATE TABLE test_ctas_123 AS SELECT key, value FROM src"), Seq.empty[Row])
143161
checkAnswer(
144-
sql("SELECT key, value FROM test_ctas_123 ORDER BY key"),
162+
sql("SELECT key, value FROM test_ctas_123 ORDER BY key"),
145163
sql("SELECT key, value FROM src ORDER BY key").collect().toSeq)
146164
}
147165

0 commit comments

Comments
 (0)