waitingF commented on code in PR #11637:
URL: https://github.com/apache/hudi/pull/11637#discussion_r1681963014


##########
hudi-common/src/test/java/org/apache/hudi/avro/TestMercifulJsonConverter.java:
##########
@@ -99,4 +106,44 @@ public void conversionWithFieldNameAliases() throws 
IOException {
 
     Assertions.assertEquals(rec, CONVERTER.convert(json, sanitizedSchema));
   }
+
+  @Test
+  public void testConvertNumberToFixed() throws IOException {
+    String testSchemaStr = "{\"type\": \"record\",\"name\": 
\"test_record\",\"namespace\": \"test_namespace\",\"fields\": "
+        + "[{\"name\": \"decimal_field\",\"type\": [\"null\",{\"type\": 
\"fixed\",\"name\": \"fixed\",\"namespace\": 
\"test_namespace.decimal_field\",\"size\": 9,"
+        + "    \"logicalType\": \"decimal\",\"precision\": 20,\"scale\": 
0}],\"default\": null},"
+        + "{\"name\": \"decimal2_field\",\"type\": [\"null\",{\"type\": 
\"fixed\",\"name\": \"fixed\",\"namespace\": 
\"test_namespace.decimal2_field\",\"size\": 9,"
+        + "    \"logicalType\": \"decimal\",\"precision\": 20,\"scale\": 
2}],\"default\": null},"
+        + "{\"name\": \"decimal3_field\",\"type\": [\"null\",{\"type\": 
\"fixed\",\"name\": \"fixed\",\"namespace\": 
\"test_namespace.decimal3_field\",\"size\": 9,"
+        + "    \"logicalType\": \"decimal\",\"precision\": 20,\"scale\": 
2}],\"default\": null},"
+        + "{\"name\": \"int_field\",\"type\": [\"null\",\"int\"],\"default\": 
null},"
+        + "{\"name\": \"long_field\",\"type\": 
[\"null\",\"long\"],\"default\": null},"
+        + "{\"name\": \"string_field\",\"type\": 
[\"null\",\"string\"],\"default\": null}]}";
+    Schema schema = Schema.parse(testSchemaStr);
+
+    String testValueStr = "{\n"
+        + "    \"decimal_field\": 1720623716,\n"

Review Comment:
   Because avro store Decimal type as Fixed type internally



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

Reply via email to