gengliangwang commented on a change in pull request #29145:
URL: https://github.com/apache/spark/pull/29145#discussion_r457973753



##########
File path: 
external/avro/src/main/scala/org/apache/spark/sql/avro/AvroFileFormat.scala
##########
@@ -128,31 +128,42 @@ private[sql] class AvroFileFormat extends FileFormat
           reader.asInstanceOf[DataFileReader[_]].getMetaString,
           SQLConf.get.getConf(SQLConf.LEGACY_AVRO_REBASE_MODE_IN_READ))
 
+        val avroFilters = if (SQLConf.get.avroFilterPushDown) {
+          new OrderedFilters(filters, requiredSchema)
+        } else {
+          new NoopFilters
+        }
+
         val deserializer = new AvroDeserializer(
-          userProvidedSchema.getOrElse(reader.getSchema), requiredSchema, 
datetimeRebaseMode)
+          userProvidedSchema.getOrElse(reader.getSchema),
+          requiredSchema,
+          datetimeRebaseMode,
+          avroFilters)
 
         new Iterator[InternalRow] {
           private[this] var completed = false
+          private[this] var nextRow: Option[InternalRow] = None
 
           override def hasNext: Boolean = {
-            if (completed) {
-              false
-            } else {
+            do {

Review comment:
       Could you create abstarction for the code below so that we can avoid 
duplication with AvroPartitionReaderFactory.scala 

##########
File path: 
external/avro/src/main/scala/org/apache/spark/sql/avro/AvroDeserializer.scala
##########
@@ -178,7 +182,7 @@ class AvroDeserializer(
         updater.setDecimal(ordinal, decimal)
 
       case (RECORD, st: StructType) =>
-        val writeRecord = getRecordWriter(avroType, st, path)
+        val writeRecord = getRecordWriter(avroType, st, path, applyFilters = _ 
=> false)

Review comment:
       Nit: add comment to explain why it is `_ => false` here




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to