Copilot commented on code in PR #9227:
URL: https://github.com/apache/seatunnel/pull/9227#discussion_r2097216296


##########
seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/sql/SQLTransformTest.java:
##########
@@ -397,7 +397,7 @@ public void tesCastBooleanClausesWithField() {
                                 new SeaTunnelRow(new Object[] 
{Integer.valueOf(1), 3, "false"}));
                     } catch (Exception e) {
                         Assertions.assertEquals(
-                                "ErrorCode:[COMMON-05], 
ErrorDescription:[Unsupported operation] - Unsupported CAST AS Boolean: 3",
+                                "ErrorCode:[TRANSFORM_COMMON-06], 
ErrorDescription:[The expression 'cast(`int` AS boolean)' of SQL transform 
execute failed]",

Review Comment:
   The expected error message uses lowercase `cast`, but the actual exception 
uses `CAST` (uppercase) from the expression's `toString()`. Update this 
assertion to match `CAST` for consistency.
   ```suggestion
                                   "ErrorCode:[TRANSFORM_COMMON-06], 
ErrorDescription:[The expression 'CAST(`int` AS boolean)' of SQL transform 
execute failed]",
   ```



##########
seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/sql/SQLTransformTest.java:
##########
@@ -411,7 +411,7 @@ public void tesCastBooleanClausesWithField() {
                                 new SeaTunnelRow(new Object[] 
{Integer.valueOf(1), 0, "false333"}));
                     } catch (Exception e) {
                         Assertions.assertEquals(
-                                "ErrorCode:[COMMON-05], 
ErrorDescription:[Unsupported operation] - Unsupported CAST AS Boolean: 
false333",
+                                "ErrorCode:[TRANSFORM_COMMON-06], 
ErrorDescription:[The expression 'cast(`string` AS boolean)' of SQL transform 
execute failed]",

Review Comment:
   The expected error message uses lowercase `cast`, but the actual exception 
uses `CAST`. Update this assertion to expect `CAST(`string` AS boolean)`.
   ```suggestion
                                   "ErrorCode:[TRANSFORM_COMMON-06], 
ErrorDescription:[The expression 'CAST(`string` AS boolean)' of SQL transform 
execute failed]",
   ```



##########
seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/sql/SQLTransformTest.java:
##########
@@ -441,4 +441,55 @@ public void tesBooleanField() {
         Assertions.assertEquals(true, result.get(0).getField(1));
         Assertions.assertEquals(false, result.get(0).getField(2));
     }
+
+    @Test
+    public void testExpressionErrorField() {
+        String tableName = "test";
+        String[] fields = new String[] {"FIELD1", "FIELD2", "FIELD3"};
+        SeaTunnelDataType[] fieldTypes =
+                new SeaTunnelDataType[] {
+                    BasicType.INT_TYPE, BasicType.DOUBLE_TYPE, 
BasicType.STRING_TYPE
+                };
+        CatalogTable table =
+                CatalogTableUtil.getCatalogTable(
+                        tableName, new SeaTunnelRowType(fields, fieldTypes));
+        String sqlQuery =
+                "select "
+                        + "CAST(`FIELD1` AS STRING) AS FIELD1, "
+                        + "CAST(`FIELD1` AS decimal(22,4)) AS FIELD2, "
+                        + "CAST(`FIELD3` AS decimal(22,0)) AS FIELD3 "
+                        + "from dual";
+
+        ReadonlyConfig config = 
ReadonlyConfig.fromMap(Collections.singletonMap("query", sqlQuery));
+        SQLTransform sqlTransform = new SQLTransform(config, table);
+        Assertions.assertThrows(
+                TransformException.class,
+                () -> {
+                    try {
+                        sqlTransform.transformRow(
+                                new SeaTunnelRow(new Object[] {1, 123.123, 
"true"}));
+                    } catch (Exception e) {
+                        Assertions.assertEquals(
+                                "ErrorCode:[TRANSFORM_COMMON-06], 
ErrorDescription:[The expression 'CAST(`FIELD3` AS decimal (22, 0))' of SQL 
transform execute failed]",

Review Comment:
   The spacing in `decimal (22, 0)` may not match the expression's `toString()` 
output (likely `decimal(22,0)`). Adjust the expected string to `CAST(`FIELD3` 
AS decimal(22,0))` to align with the actual error message.
   ```suggestion
                                   "ErrorCode:[TRANSFORM_COMMON-06], 
ErrorDescription:[The expression 'CAST(`FIELD3` AS decimal(22,0))' of SQL 
transform execute failed]",
   ```



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