@@ -199,18 +199,27 @@ abstract class OrcSuite extends QueryTest with TestHiveSingleton with BeforeAndA
199
199
200
200
test(" SPARK-21839: Add SQL config for ORC compression" ) {
201
201
val conf = sqlContext.sessionState.conf
202
+ // Test if the default of spark.sql.orc.compression.codec is snappy
202
203
assert(new OrcOptions (Map .empty[String , String ], conf).compressionCodec == " SNAPPY" )
203
204
204
205
// OrcOptions's parameters have a higher priority than SQL configuration.
206
+ // `compression` -> `orc.compression` -> `spark.sql.orc.compression.codec`
205
207
withSQLConf(SQLConf .ORC_COMPRESSION .key -> " uncompressed" ) {
206
208
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" )
209
213
}
210
214
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 =>
212
217
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
+ }
214
223
}
215
224
}
216
225
}
0 commit comments