wuchong commented on a change in pull request #14604:
URL: https://github.com/apache/flink/pull/14604#discussion_r556296636



##########
File path: 
flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowDataSerDeSchemaTest.java
##########
@@ -562,6 +578,55 @@ public void testSerializationMapNullKey() throws Exception 
{
         assertEquals(expectResult3, new String(actual3));
     }
 
+    @Test
+    public void testSerializationDecimalEncode() throws Exception {
+        String original =
+                
"{\"decimal1\":123.456789,\"decimal2\":454621864049246170,\"decimal3\":0.000000027}";
+        String expectedWithPlainDecimal =
+                
"{\"decimal1\":123.456789,\"decimal2\":454621864049246170,\"decimal3\":0.000000027}";

Review comment:
       1. They are equal? We may only need to declare just one 
`plainDecimalJson`?
   2. Please move the variable near where it is used. 
   

##########
File path: 
flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowDataSerDeSchemaTest.java
##########
@@ -562,6 +578,55 @@ public void testSerializationMapNullKey() throws Exception 
{
         assertEquals(expectResult3, new String(actual3));
     }
 
+    @Test
+    public void testSerializationDecimalEncode() throws Exception {
+        String original =
+                
"{\"decimal1\":123.456789,\"decimal2\":454621864049246170,\"decimal3\":0.000000027}";
+        String expectedWithPlainDecimal =
+                
"{\"decimal1\":123.456789,\"decimal2\":454621864049246170,\"decimal3\":0.000000027}";
+        String expectedWithoutPlainDecimal =
+                
"{\"decimal1\":123.456789,\"decimal2\":4.5462186404924617E+17,\"decimal3\":2.7E-8}";

Review comment:
       1. We can call this `scientificDecimalJson`. 
   2. Please move the variable near where it is used. 

##########
File path: 
flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowDataSerDeSchemaTest.java
##########
@@ -562,6 +578,55 @@ public void testSerializationMapNullKey() throws Exception 
{
         assertEquals(expectResult3, new String(actual3));
     }
 
+    @Test
+    public void testSerializationDecimalEncode() throws Exception {
+        String original =
+                
"{\"decimal1\":123.456789,\"decimal2\":454621864049246170,\"decimal3\":0.000000027}";
+        String expectedWithPlainDecimal =
+                
"{\"decimal1\":123.456789,\"decimal2\":454621864049246170,\"decimal3\":0.000000027}";
+        String expectedWithoutPlainDecimal =
+                
"{\"decimal1\":123.456789,\"decimal2\":4.5462186404924617E+17,\"decimal3\":2.7E-8}";
+
+        RowType schema =
+                (RowType)
+                        ROW(
+                                        FIELD("decimal1", DECIMAL(9, 6)),
+                                        FIELD("decimal2", DECIMAL(20, 0)),
+                                        FIELD("decimal3", DECIMAL(11, 9)))
+                                .getLogicalType();
+
+        TypeInformation<RowData> resultTypeInfo = InternalTypeInfo.of(schema);
+
+        JsonRowDataDeserializationSchema deserializationSchema =
+                new JsonRowDataDeserializationSchema(
+                        schema, resultTypeInfo, false, false, 
TimestampFormat.ISO_8601);
+
+        JsonRowDataSerializationSchema serializationSchemaWithPlainDecimal =
+                new JsonRowDataSerializationSchema(
+                        schema,
+                        TimestampFormat.ISO_8601,
+                        JsonOptions.MapNullKeyMode.LITERAL,
+                        "null",
+                        true);
+        JsonRowDataSerializationSchema serializationSchemaWithoutPlainDecimal =

Review comment:
       `scientificDecimalSerializer`

##########
File path: 
flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowDataSerDeSchemaTest.java
##########
@@ -562,6 +578,55 @@ public void testSerializationMapNullKey() throws Exception 
{
         assertEquals(expectResult3, new String(actual3));
     }
 
+    @Test
+    public void testSerializationDecimalEncode() throws Exception {
+        String original =
+                
"{\"decimal1\":123.456789,\"decimal2\":454621864049246170,\"decimal3\":0.000000027}";
+        String expectedWithPlainDecimal =
+                
"{\"decimal1\":123.456789,\"decimal2\":454621864049246170,\"decimal3\":0.000000027}";
+        String expectedWithoutPlainDecimal =
+                
"{\"decimal1\":123.456789,\"decimal2\":4.5462186404924617E+17,\"decimal3\":2.7E-8}";
+
+        RowType schema =
+                (RowType)
+                        ROW(
+                                        FIELD("decimal1", DECIMAL(9, 6)),
+                                        FIELD("decimal2", DECIMAL(20, 0)),
+                                        FIELD("decimal3", DECIMAL(11, 9)))
+                                .getLogicalType();
+
+        TypeInformation<RowData> resultTypeInfo = InternalTypeInfo.of(schema);
+
+        JsonRowDataDeserializationSchema deserializationSchema =
+                new JsonRowDataDeserializationSchema(
+                        schema, resultTypeInfo, false, false, 
TimestampFormat.ISO_8601);
+
+        JsonRowDataSerializationSchema serializationSchemaWithPlainDecimal =

Review comment:
       `plainDecimalSerializer`




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to