aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/core/src/main/scala/org/apache/spark/sql/internal/HiveSerDe.scala3
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLCommandSuite.scala15
2 files changed, 18 insertions, 0 deletions
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/internal/HiveSerDe.scala b/sql/core/src/main/scala/org/apache/spark/sql/internal/HiveSerDe.scala
index d554937d8b..ad69137f74 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/internal/HiveSerDe.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/internal/HiveSerDe.scala
@@ -71,6 +71,9 @@ object HiveSerDe {
val key = source.toLowerCase match {
case s if s.startsWith("org.apache.spark.sql.parquet") => "parquet"
case s if s.startsWith("org.apache.spark.sql.orc") => "orc"
+ case s if s.equals("orcfile") => "orc"
+ case s if s.equals("parquetfile") => "parquet"
+ case s if s.equals("avrofile") => "avro"
case s => s
}
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLCommandSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLCommandSuite.scala
index 850fca5852..aec7e99d9d 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLCommandSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLCommandSuite.scala
@@ -237,6 +237,21 @@ class DDLCommandSuite extends PlanTest {
comparePlans(parsed4, expected4)
}
+ test("create table - table file format") {
+ val allSources = Seq("parquet", "parquetfile", "orc", "orcfile", "avro", "avrofile",
+ "sequencefile", "rcfile", "textfile")
+
+ allSources.foreach { s =>
+ val query = s"CREATE TABLE my_tab STORED AS $s"
+ val ct = parseAs[CreateTableCommand](query)
+ val hiveSerde = HiveSerDe.sourceToSerDe(s, new SQLConf)
+ assert(hiveSerde.isDefined)
+ assert(ct.table.storage.serde == hiveSerde.get.serde)
+ assert(ct.table.storage.inputFormat == hiveSerde.get.inputFormat)
+ assert(ct.table.storage.outputFormat == hiveSerde.get.outputFormat)
+ }
+ }
+
test("create table - row format and table file format") {
val createTableStart = "CREATE TABLE my_tab ROW FORMAT"
val fileFormat = s"STORED AS INPUTFORMAT 'inputfmt' OUTPUTFORMAT 'outputfmt'"