amaliujia commented on code in PR #38068:
URL: https://github.com/apache/spark/pull/38068#discussion_r985131741
##########
connector/avro/src/test/scala/org/apache/spark/sql/avro/AvroSerdeSuite.scala:
##########
@@ -49,6 +49,22 @@ class AvroSerdeSuite extends SparkFunSuite {
}
}
+ test("Test byte conversion") {
+ withFieldMatchType { fieldMatch =>
+ val (top, nest) = fieldMatch match {
+ case BY_NAME => ("foo", "bar")
+ case BY_POSITION => ("NOTfoo", "NOTbar")
+ }
+ val avro = createNestedAvroSchemaWithFields(top, _.optionalInt(nest))
+ val record = new GenericRecordBuilder(avro)
+ .set(top, new
GenericRecordBuilder(avro.getField(top).schema()).set(nest, -128).build())
+ .build()
+ val serializer = Serializer.create(CATALYST_STRUCT_WITH_BYTE, avro,
fieldMatch)
+ val deserializer = Deserializer.create(CATALYST_STRUCT_WITH_BYTE, avro,
fieldMatch)
+ assert(serializer.serialize(deserializer.deserialize(record).get) ===
record)
Review Comment:
I think you also need another test for that dataframe schema is BYTE type,
write to AVRO file and then the read based on the schema with byte type can
succeed with expected result.
--
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]