-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Feature][Transform] support boolean type for sql transform #9136
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
Conversation
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.
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() {
...forms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/functions/SystemFunction.java
Outdated
Show resolved
Hide resolved
600c9b5
to
3ebd933
Compare
cc @hailin0 |
Please update the doc. |
if (("true".equalsIgnoreCase(columnExp.getColumnName()) | ||
|| "false".equalsIgnoreCase(columnExp.getColumnName())) | ||
&& ("CaseWhenExpression".equalsIgnoreCase(node.toString()))) { | ||
return Boolean.parseBoolean(columnExp.getColumnName()); | ||
} |
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.
Why not directly return StringValue
in here? Then parse it to boolean in cast method.
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.
Node node = columnExp.getASTNode().jjtGetParent(); | ||
if (("true".equalsIgnoreCase(columnExp.getColumnName()) | ||
|| "false".equalsIgnoreCase(columnExp.getColumnName())) | ||
&& ("CaseWhenExpression".equalsIgnoreCase(node.toString()))) { | ||
return BasicType.BOOLEAN_TYPE; | ||
} |
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.
ditto
aed02df
to
b2fed4e
Compare
Purpose of this pull request
support boolean type for sql transform. eg:
select ( case when
col1
= 'a' then true else false end ) asbool_1
, cast(col2
as boolean) asbool_2
asbool_2
from dualnote:
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
New License Guide
release-note
.