Skip to content

Commit

Permalink
Add a test for an illegal codec given in an option
Browse files Browse the repository at this point in the history
  • Loading branch information
maropu committed Feb 27, 2016
1 parent 2d7737b commit da879a6
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,21 @@ class TextSuite extends QueryTest with SharedSQLContext {
}

test("SPARK-13503 Support to specify the option for compression codec for TEXT") {
val testDf = sqlContext.read.text(testFile)

Seq("bzip2", "deflate", "gzip").map { codecName =>
val tempDir = Utils.createTempDir()
val tempDirPath = tempDir.getAbsolutePath()
val df = sqlContext.read.text(testFile)
df.write.option("compression", codecName).mode(SaveMode.Overwrite).text(tempDirPath)
testDf.write.option("compression", codecName).mode(SaveMode.Overwrite).text(tempDirPath)
verifyFrame(sqlContext.read.text(tempDirPath))
}

val errMsg = intercept[IllegalArgumentException] {
val tempDirPath = Utils.createTempDir().getAbsolutePath()
testDf.write.option("compression", "illegal").mode(SaveMode.Overwrite).text(tempDirPath)
}
assert(errMsg.getMessage === "Codec [illegal] is not available. " +
"Known codecs are bzip2, deflate, lz4, gzip, snappy.")
}

private def testFile: String = {
Expand Down

0 comments on commit da879a6

Please sign in to comment.