amaliujia commented on code in PR #38068:
URL: https://github.com/apache/spark/pull/38068#discussion_r985306024


##########
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:
   Oh yes I really meant `saveAsTable`. The reason is this test is just test 
`BYTE` is ser/deser. Then based on the PR description we need to trigger that 
the preserved avro table schema still contains a byte field.
   
   Maybe this is a right suite for the test 
https://github.com/apache/spark/blob/master/connector/avro/src/test/scala/org/apache/spark/sql/avro/AvroSuite.scala?



##########
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:
   Oh yes I really meant `saveAsTable`. The reason is this test is just test 
`BYTE` in ser/deser. Then based on the PR description we need to trigger that 
the preserved avro table schema still contains a byte field case.
   
   Maybe this is a right suite for the test 
https://github.com/apache/spark/blob/master/connector/avro/src/test/scala/org/apache/spark/sql/avro/AvroSuite.scala?



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

Reply via email to