MaxGekk commented on a change in pull request #29145:
URL: https://github.com/apache/spark/pull/29145#discussion_r462335152
##########
File path:
external/avro/src/test/scala/org/apache/spark/sql/avro/AvroCatalystDataConversionSuite.scala
##########
@@ -287,30 +309,53 @@ class AvroCatalystDataConversionSuite extends
SparkFunSuite
|}
""".stripMargin
val avroSchema = new Schema.Parser().parse(jsonFormatSchema)
- val dataType = SchemaConverters.toSqlType(avroSchema).dataType
- val deserializer = new AvroDeserializer(avroSchema, dataType)
-
- def checkDeserialization(data: GenericData.Record, expected: Any): Unit = {
- assert(checkResult(
- expected,
- deserializer.deserialize(data),
- dataType, exprNullable = false
- ))
- }
def validateDeserialization(array: java.util.Collection[Integer]): Unit = {
val data = new GenericRecordBuilder(avroSchema)
.set("array", array)
.build()
val expected = InternalRow(new GenericArrayData(new
util.ArrayList[Any](array)))
- checkDeserialization(data, expected)
+ checkDeserialization(avroSchema, data, Some(expected))
val reEncoded = new BinaryMessageDecoder[GenericData.Record](new
GenericData(), avroSchema)
.decode(new BinaryMessageEncoder(new GenericData(),
avroSchema).encode(data))
- checkDeserialization(reEncoded, expected)
+ checkDeserialization(avroSchema, reEncoded, Some(expected))
}
validateDeserialization(Collections.emptySet())
validateDeserialization(util.Arrays.asList(1, null, 3))
}
+
+ test("SPARK-32346: filter pushdown to Avro deserializer") {
+ val schema =
+ """
+ |{
+ | "type" : "record",
+ | "name" : "test_schema",
+ | "fields" : [
+ | {"name": "Age", "type": "int"},
+ | {"name": "Name", "type": "string"}
+ | ]
+ |}
+ """.stripMargin
+ val avroSchema = new Schema.Parser().parse(schema)
+ val sqlSchema = new StructType().add("Age", "int").add("Name", "string")
+ val data = new GenericRecordBuilder(avroSchema)
+ .set("Age", 39)
Review comment:
This test checks Avro deserializer which accepts ONE avro record and
return None or Some(InternalRow). So, the test covers both cases. I am just
wondering what do you mean by `more rows`?
----------------------------------------------------------------
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]