Skip to content

Commit aafbfbb

Browse files
committed
Address comments.
1 parent 437d181 commit aafbfbb

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

sql/hive/src/test/scala/org/apache/spark/sql/hive/orc/OrcSourceSuite.scala

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,27 @@ abstract class OrcSuite extends QueryTest with TestHiveSingleton with BeforeAndA
199199

200200
test("SPARK-21839: Add SQL config for ORC compression") {
201201
val conf = sqlContext.sessionState.conf
202+
// Test if the default of spark.sql.orc.compression.codec is snappy
202203
assert(new OrcOptions(Map.empty[String, String], conf).compressionCodec == "SNAPPY")
203204

204205
// OrcOptions's parameters have a higher priority than SQL configuration.
206+
// `compression` -> `orc.compression` -> `spark.sql.orc.compression.codec`
205207
withSQLConf(SQLConf.ORC_COMPRESSION.key -> "uncompressed") {
206208
assert(new OrcOptions(Map.empty[String, String], conf).compressionCodec == "NONE")
207-
assert(
208-
new OrcOptions(Map("orc.compress" -> "zlib"), conf).compressionCodec == "ZLIB")
209+
val map1 = Map("orc.compress" -> "zlib")
210+
val map2 = Map("orc.compress" -> "zlib", "compression" -> "lzo")
211+
assert(new OrcOptions(map1, conf).compressionCodec == "ZLIB")
212+
assert(new OrcOptions(map2, conf).compressionCodec == "LZO")
209213
}
210214

211-
Seq("NONE", "SNAPPY", "ZLIB", "LZO").foreach { c =>
215+
// Test all the valid options of spark.sql.orc.compression.codec
216+
Seq("NONE", "UNCOMPRESSED", "SNAPPY", "ZLIB", "LZO").foreach { c =>
212217
withSQLConf(SQLConf.ORC_COMPRESSION.key -> c) {
213-
assert(new OrcOptions(Map.empty[String, String], conf).compressionCodec == c)
218+
if (c == "UNCOMPRESSED") {
219+
assert(new OrcOptions(Map.empty[String, String], conf).compressionCodec == "NONE")
220+
} else {
221+
assert(new OrcOptions(Map.empty[String, String], conf).compressionCodec == c)
222+
}
214223
}
215224
}
216225
}

0 commit comments

Comments
 (0)