yht0827 commented on code in PR #10390:
URL: https://github.com/apache/seatunnel/pull/10390#discussion_r2752674821


##########
seatunnel-formats/seatunnel-format-json/src/test/java/org/apache/seatunnel/format/json/JsonRowDataSerDeSchemaTest.java:
##########
@@ -713,4 +713,54 @@ public void testSerializationWithNumber() {
         String expected = "{\"id\":1,\"code\":\"1001015\",\"fe_result\":80}";
         assertEquals(new String(serialize), expected);
     }
+
+    @Test
+    public void testConvertToLocalDateWithEmptyString() throws IOException {
+        SeaTunnelRowType rowType =
+                new SeaTunnelRowType(
+                        new String[] {"date_field"},
+                        new SeaTunnelDataType<?>[] 
{LocalTimeType.LOCAL_DATE_TYPE});
+        JsonDeserializationSchema deserializationSchema =
+                new JsonDeserializationSchema(false, false, rowType);
+
+        // Test empty string
+        String emptyDateJson = "{\"date_field\":\"\"}";
+        SeaTunnelRow row = 
deserializationSchema.deserialize(emptyDateJson.getBytes());
+        assertNull(row.getField(0));
+
+        // Test whitespace only string
+        String whitespaceJson = "{\"date_field\":\"   \"}";
+        row = deserializationSchema.deserialize(whitespaceJson.getBytes());
+        assertNull(row.getField(0));
+
+        // Test normal date value still works
+        String normalDateJson = "{\"date_field\":\"2024-01-15\"}";
+        row = deserializationSchema.deserialize(normalDateJson.getBytes());
+        assertEquals(LocalDate.of(2024, 1, 15), row.getField(0));
+    }
+
+    @Test
+    public void testConvertToLocalDateTimeWithEmptyString() throws IOException 
{
+        SeaTunnelRowType rowType =
+                new SeaTunnelRowType(
+                        new String[] {"timestamp_field"},
+                        new SeaTunnelDataType<?>[] 
{LocalTimeType.LOCAL_DATE_TIME_TYPE});
+        JsonDeserializationSchema deserializationSchema =
+                new JsonDeserializationSchema(false, false, rowType);
+
+        // Test empty string
+        String emptyTimestampJson = "{\"timestamp_field\":\"\"}";
+        SeaTunnelRow row = 
deserializationSchema.deserialize(emptyTimestampJson.getBytes());
+        assertNull(row.getField(0));
+
+        // Test whitespace only string
+        String whitespaceJson = "{\"timestamp_field\":\"   \"}";
+        row = deserializationSchema.deserialize(whitespaceJson.getBytes());
+        assertNull(row.getField(0));
+
+        // Test normal timestamp value still works
+        String normalTimestampJson = "{\"timestamp_field\":\"2024-01-15 
10:30:00\"}";
+        row = 
deserializationSchema.deserialize(normalTimestampJson.getBytes());
+        assertEquals(LocalDateTime.of(2024, 1, 15, 10, 30, 0), 
row.getField(0));
+    }

Review Comment:
   The empty-string-to-null check logic was reverted, so I removed the related 
tests for empty strings.
    also, Added testMultipleDateColumnsWithDifferentFormats to ensure multiple 
date columns with different patterns (yyyy-MM-dd, yyyy.MM.dd) are parsed 
independently and correctly.



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