Skip to content

Conversation

@hawk9821
Copy link
Contributor

Purpose of this pull request

support boolean type for sql transform. eg:
select ( case when col1 = 'a' then true else false end ) as bool_1 , cast( col2 as boolean) as bool_2 as bool_2 from dual
note:
cast column value must is (1,0) or ('true','false')

Does this PR introduce any user-facing change?

How was this patch tested?

Check list

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/sql/SQLTransformTest.java:321

  • [nitpick] Consider renaming the test method to 'testCaseWhenBooleanClausesWithField' for clarity and consistency with naming conventions.
public void tesCaseWhenBooleanClausesWithField() {

seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/sql/SQLTransformTest.java:356

  • [nitpick] Consider renaming the test method to 'testCastBooleanClausesWithField' for clarity and consistency with naming conventions.
public void tesCastBooleanClausesWithField() {

@hawk9821 hawk9821 force-pushed the transform_boolean branch from 600c9b5 to 3ebd933 Compare April 10, 2025 07:05
@Hisoka-X
Copy link
Member

cc @hailin0

@Hisoka-X
Copy link
Member

Please update the doc.

Comment on lines 268 to 272
if (("true".equalsIgnoreCase(columnExp.getColumnName())
|| "false".equalsIgnoreCase(columnExp.getColumnName()))
&& ("CaseWhenExpression".equalsIgnoreCase(node.toString()))) {
return Boolean.parseBoolean(columnExp.getColumnName());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not directly return StringValue in here? Then parse it to boolean in cast method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 118 to 123
Node node = columnExp.getASTNode().jjtGetParent();
if (("true".equalsIgnoreCase(columnExp.getColumnName())
|| "false".equalsIgnoreCase(columnExp.getColumnName()))
&& ("CaseWhenExpression".equalsIgnoreCase(node.toString()))) {
return BasicType.BOOLEAN_TYPE;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@hawk9821 hawk9821 force-pushed the transform_boolean branch from aed02df to b2fed4e Compare April 17, 2025 08:59
@hailin0 hailin0 merged commit 6897367 into apache:dev Apr 21, 2025
5 checks passed
hawk9821 added a commit to hawk9821/seatunnel that referenced this pull request Apr 22, 2025
@hawk9821 hawk9821 deleted the transform_boolean branch April 25, 2025 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants