@@ -58,6 +58,7 @@ private[avro] class AvroFileFormat extends FileFormat with DataSourceRegister {
5858 options : Map [String , String ],
5959 files : Seq [FileStatus ]): Option [StructType ] = {
6060 val conf = spark.sparkContext.hadoopConfiguration
61+ val parsedOptions = new AvroOptions (options)
6162
6263 // Schema evolution is not supported yet. Here we only pick a single random sample file to
6364 // figure out the schema of the whole dataset.
@@ -74,7 +75,7 @@ private[avro] class AvroFileFormat extends FileFormat with DataSourceRegister {
7475 }
7576
7677 // User can specify an optional avro json schema.
77- val avroSchema = options.get( AvroFileFormat . AvroSchema )
78+ val avroSchema = parsedOptions.schema
7879 .map(new Schema .Parser ().parse)
7980 .getOrElse {
8081 val in = new FsInput (sampleFile.getPath, conf)
@@ -112,10 +113,9 @@ private[avro] class AvroFileFormat extends FileFormat with DataSourceRegister {
112113 job : Job ,
113114 options : Map [String , String ],
114115 dataSchema : StructType ): OutputWriterFactory = {
115- val recordName = options.getOrElse(" recordName" , " topLevelRecord" )
116- val recordNamespace = options.getOrElse(" recordNamespace" , " " )
116+ val parsedOptions = new AvroOptions (options)
117117 val outputAvroSchema = SchemaConverters .toAvroType(
118- dataSchema, nullable = false , recordName, recordNamespace)
118+ dataSchema, nullable = false , parsedOptions. recordName, parsedOptions. recordNamespace)
119119
120120 AvroJob .setOutputKeySchema(job, outputAvroSchema)
121121 val AVRO_COMPRESSION_CODEC = " spark.sql.avro.compression.codec"
@@ -158,11 +158,12 @@ private[avro] class AvroFileFormat extends FileFormat with DataSourceRegister {
158158
159159 val broadcastedConf =
160160 spark.sparkContext.broadcast(new AvroFileFormat .SerializableConfiguration (hadoopConf))
161+ val parsedOptions = new AvroOptions (options)
161162
162163 (file : PartitionedFile ) => {
163164 val log = LoggerFactory .getLogger(classOf [AvroFileFormat ])
164165 val conf = broadcastedConf.value.value
165- val userProvidedSchema = options.get( AvroFileFormat . AvroSchema ) .map(new Schema .Parser ().parse)
166+ val userProvidedSchema = parsedOptions.schema .map(new Schema .Parser ().parse)
166167
167168 // TODO Removes this check once `FileFormat` gets a general file filtering interface method.
168169 // Doing input file filtering is improper because we may generate empty tasks that process no
@@ -233,8 +234,6 @@ private[avro] class AvroFileFormat extends FileFormat with DataSourceRegister {
233234private [avro] object AvroFileFormat {
234235 val IgnoreFilesWithoutExtensionProperty = " avro.mapred.ignore.inputs.without.extension"
235236
236- val AvroSchema = " avroSchema"
237-
238237 class SerializableConfiguration (@ transient var value : Configuration )
239238 extends Serializable with KryoSerializable {
240239 @ transient private [avro] lazy val log = LoggerFactory .getLogger(getClass)
0 commit comments