brkyvz commented on code in PR #38113:
URL: https://github.com/apache/spark/pull/38113#discussion_r989451837
##########
connector/avro/src/main/scala/org/apache/spark/sql/avro/AvroOptions.scala:
##########
@@ -116,21 +121,27 @@ private[sql] class AvroOptions(
* taken into account. If the former one is not set too, the `snappy` codec
is used by default.
*/
val compression: String = {
- parameters.get("compression").getOrElse(SQLConf.get.avroCompressionCodec)
+ parameters.get(COMPRESSION).getOrElse(SQLConf.get.avroCompressionCodec)
}
val parseMode: ParseMode =
- parameters.get("mode").map(ParseMode.fromString).getOrElse(FailFastMode)
+ parameters.get(MODE).map(ParseMode.fromString).getOrElse(FailFastMode)
/**
* The rebasing mode for the DATE and TIMESTAMP_MICROS, TIMESTAMP_MILLIS
values in reads.
*/
val datetimeRebaseModeInRead: String = parameters
- .get(AvroOptions.DATETIME_REBASE_MODE)
+ .get(DATETIME_REBASE_MODE)
.getOrElse(SQLConf.get.getConf(SQLConf.AVRO_REBASE_MODE_IN_READ))
}
private[sql] object AvroOptions {
+ val avroOptionNames: mutable.Set[String] = collection.mutable.Set[String]()
+ private def newOption(name: String): String = {
+ avroOptionNames += name.toLowerCase(Locale.ROOT)
+ name
+ }
+
Review Comment:
you should just abstract this out into a `trait` in sql/core instead of
defining it individually for all data sources.
One other thing that's interesting is having to deal with alternative names
for some of these options. Maybe `newOption` can take an alternative name as
well. You'll see this with CSV for sep and delimeter. You need to register
both, but also know of the relationship
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]