Skip to content

Commit

Permalink
When hive.default.fileformat is other kinds of file types,
Browse files Browse the repository at this point in the history
create textfile table cause a serde error
  • Loading branch information
cxzl25 committed Feb 13, 2018
1 parent 14b5dbf commit 979323a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ object HiveSerDe {
"sequencefile" ->
HiveSerDe(
inputFormat = Option("org.apache.hadoop.mapred.SequenceFileInputFormat"),
outputFormat = Option("org.apache.hadoop.mapred.SequenceFileOutputFormat")),
outputFormat = Option("org.apache.hadoop.mapred.SequenceFileOutputFormat"),
serde = Option("org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe")),

"rcfile" ->
HiveSerDe(
Expand All @@ -54,7 +55,8 @@ object HiveSerDe {
"textfile" ->
HiveSerDe(
inputFormat = Option("org.apache.hadoop.mapred.TextInputFormat"),
outputFormat = Option("org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat")),
outputFormat = Option("org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"),
serde = Option("org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe")),

"avro" ->
HiveSerDe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,25 @@ class HiveDDLCommandSuite extends PlanTest with SQLTestUtils with TestHiveSingle
assert(output == Some("org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat"))
assert(serde == Some("org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe"))
}

withSQLConf("hive.default.fileformat" -> "orc") {
val (desc, exists) = extractTableDesc(
"CREATE TABLE IF NOT EXISTS fileformat_test (id int) STORED AS textfile")
assert(exists)
assert(desc.storage.inputFormat == Some("org.apache.hadoop.mapred.TextInputFormat"))
assert(desc.storage.outputFormat ==
Some("org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"))
assert(desc.storage.serde == Some("org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe"))
}

withSQLConf("hive.default.fileformat" -> "orc") {
val (desc, exists) = extractTableDesc(
"CREATE TABLE IF NOT EXISTS fileformat_test (id int) STORED AS sequencefile")
assert(exists)
assert(desc.storage.inputFormat == Some("org.apache.hadoop.mapred.SequenceFileInputFormat"))
assert(desc.storage.outputFormat == Some("org.apache.hadoop.mapred.SequenceFileOutputFormat"))
assert(desc.storage.serde == Some("org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe"))
}
}

test("table name with schema") {
Expand Down

0 comments on commit 979323a

Please sign in to comment.