Github user aarondav commented on a diff in the pull request:
https://github.com/apache/spark/pull/10805#discussion_r50206066
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/CSVParameters.scala
---
@@ -107,3 +114,28 @@ private[csv] object ParseModes {
true // We default to permissive is the mode string is not valid
}
}
+
+private[csv] object CSVCompressionCodecs {
+ private val shortCompressionCodecNames = Map(
+ "bzip2" -> classOf[BZip2Codec].getName,
+ "gzip" -> classOf[GzipCodec].getName,
+ "lz4" -> classOf[Lz4Codec].getName,
+ "snappy" -> classOf[SnappyCodec].getName)
+
+ /**
+ * Return the full version of the given codec class.
+ * If it is already a class name, just return it.
+ */
+ def getCodecClassName(name: String): String = {
+ val codecName = shortCompressionCodecNames.getOrElse(name.toLowerCase,
name)
+ val codecClassName = try {
+ // Validate the codec name
+ Utils.classForName(codecName)
+ Some(codecName)
+ } catch {
+ case e: ClassNotFoundException => None
+ }
+ codecClassName.getOrElse(throw new IllegalArgumentException(s"Codec
[$codecName] " +
--- End diff --
should just put this throw inside the catch block and not bother with the
Option stuff
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]