-
Notifications
You must be signed in to change notification settings - Fork 2k
[Improve][Transform-V2] Improve sql transform exception to locate error expression #9227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
75e8310
38eef59
e461da3
59d4fda
f786dac
be184d1
d76b087
683530c
c433c94
aeeddb7
bfe9ef9
8efc95b
42a11a5
309ade7
e88bc6e
cba7ad7
276eea7
a0649d8
fd1eee7
259dcf3
f1c79a3
8b59d9f
41c3ac1
c70781a
0065e76
16c5ee6
58bce88
a805e26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -397,8 +397,11 @@ 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]", | ||||||
e.getMessage()); | ||||||
Assertions.assertEquals( | ||||||
"ErrorCode:[COMMON-05], ErrorDescription:[Unsupported operation] - Unsupported CAST AS Boolean: 3", | ||||||
e.getCause().getMessage()); | ||||||
throw e; | ||||||
} | ||||||
}); | ||||||
|
@@ -411,8 +414,11 @@ 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", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new exception looks like lose expression value in message. We should fix it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. already complete |
||||||
"ErrorCode:[TRANSFORM_COMMON-06], ErrorDescription:[The expression 'cast(`string` AS boolean)' of SQL transform execute failed]", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The expected error message uses lowercase
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
e.getMessage()); | ||||||
Assertions.assertEquals( | ||||||
"ErrorCode:[COMMON-05], ErrorDescription:[Unsupported operation] - Unsupported CAST AS Boolean: false333", | ||||||
e.getCause().getMessage()); | ||||||
throw e; | ||||||
} | ||||||
}); | ||||||
|
@@ -441,4 +447,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"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should handle |
||||||
|
||||||
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]", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spacing in
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
e.getMessage()); | ||||||
throw e; | ||||||
} | ||||||
}); | ||||||
sqlQuery = "select * from dual where FIELD1/0 > 10"; | ||||||
config = ReadonlyConfig.fromMap(Collections.singletonMap("query", sqlQuery)); | ||||||
SQLTransform sqlTransform2 = new SQLTransform(config, table); | ||||||
Assertions.assertThrows( | ||||||
TransformException.class, | ||||||
() -> { | ||||||
try { | ||||||
sqlTransform2.transformRow( | ||||||
new SeaTunnelRow(new Object[] {1, 123.123, "true"})); | ||||||
} catch (Exception e) { | ||||||
Assertions.assertEquals( | ||||||
"ErrorCode:[TRANSFORM_COMMON-07], ErrorDescription:[The where statement 'FIELD1 / 0 > 10' of SQL transform execute failed]", | ||||||
e.getMessage()); | ||||||
throw e; | ||||||
} | ||||||
}); | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expected error message uses lowercase
cast
, but the actual exception usesCAST
(uppercase) from the expression'stoString()
. Update this assertion to matchCAST
for consistency.Copilot uses AI. Check for mistakes.