misi1987107 commented on code in PR #10000:
URL: https://github.com/apache/seatunnel/pull/10000#discussion_r2512684199


##########
seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/sql/zeta/CastFunctionTest.java:
##########
@@ -54,4 +55,29 @@ public void testCastFunction() {
         Assertions.assertEquals(Byte.parseByte("1"), f2Object);
         Assertions.assertEquals(Short.parseShort("1"), f3Object);
     }
+
+    @Test
+    public void testCastFunctionWithNullNestedField() {
+        SQLEngine sqlEngine = 
SQLEngineFactory.getSQLEngine(SQLEngineFactory.EngineType.ZETA);
+
+        SeaTunnelRowType rowType =
+                new SeaTunnelRowType(
+                        new String[] {"user"},
+                        new SeaTunnelDataType[] {
+                            new MapType<>(BasicType.STRING_TYPE, 
BasicType.STRING_TYPE)
+                        });
+
+        SeaTunnelRow inputRow = new SeaTunnelRow(new Object[] {null});
+
+        sqlEngine.init("test", null, rowType, "select user.address as address 
from test");
+
+        SeaTunnelRowType outRowType = sqlEngine.typeMapping(null);
+
+        SeaTunnelRow outRow = sqlEngine.transformBySQL(inputRow, 
outRowType).get(0);
+
+        Object addressField = outRow.getField(0);
+        Assertions.assertNull(
+                addressField,
+                "When casting nested field where intermediate value is null, 
result should be null");
+    }

Review Comment:
   OK,I will add some normal scenarios test cases.



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