gengliangwang commented on a change in pull request #31490: URL: https://github.com/apache/spark/pull/31490#discussion_r660295813
########## File path: external/avro/src/test/scala/org/apache/spark/sql/avro/AvroSerdeSuite.scala ########## @@ -144,6 +173,43 @@ object AvroSerdeSuite { private val CATALYST_STRUCT = new StructType().add("foo", new StructType().add("bar", IntegerType)) + /** + * Specifier for type of serde to be used for easy creation of tests that do both + * serialization and deserialization. + */ + object SerdeType extends Enumeration { + type SerdeType = Value + val SERIALIZE, DESERIALIZE = Value + } + import SerdeType._ + + /** + * Specifier for type of field matching to be used for easy creation of tests that do both + * positional and by-name field matching. + */ + object FieldMatchType extends Enumeration { + type FieldMatchType = Value + val BY_NAME, BY_POSITION = Value + } + import FieldMatchType._ + + private def createSerde( + catalystSchema: StructType, + avroSchema: Schema, + serdeType: SerdeType, + fieldMatchType: FieldMatchType): Either[AvroSerializer, AvroDeserializer] = { + val positional = fieldMatchType match { + case BY_NAME => false + case BY_POSITION => true + } + serdeType match { + case SERIALIZE => Left(new AvroSerializer(catalystSchema, avroSchema, false, positional, Review comment: QQ: why using Left/Right 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. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org