-
Notifications
You must be signed in to change notification settings - Fork 5k
[Fix-17701][SqlTask] handle duplicate column aliases in SQL result by appending column index suffix #17702
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
base: dev
Are you sure you want to change the base?
Conversation
SbloodyS
left a comment
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.
Please add some ut to test it. @njnu-seafish
ok |
SbloodyS
left a comment
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.
Please don't directly use code generated by AI.
...hinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
Outdated
Show resolved
Hide resolved
...hinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
Outdated
Show resolved
Hide resolved
...hinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
Outdated
Show resolved
Hide resolved
...hinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
Outdated
Show resolved
Hide resolved
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.
Pull request overview
This PR fixes issue #17701 by implementing a deduplication mechanism for duplicate column aliases in SQL query results. When SQL queries return columns with the same label, the system now appends numeric suffixes (_2, _3, etc.) to make them unique in the JSON output.
Key Changes
- Introduced duplicate column detection using a HashSet per row to track used labels
- Implemented fallback naming ("col_N") for null or empty column labels
- Added comprehensive test coverage with 9 new test cases covering edge cases including suffix collisions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| SqlTask.java | Core implementation: Added deduplication logic with HashSet tracking, null/empty label handling with "col_" prefix, and enhanced error handling with try-catch around ResultSet.getObject() |
| SqlTaskTest.java | Added 9 comprehensive test cases covering null ResultSet, empty ResultSet, null/empty column labels, duplicate columns, and complex suffix collision scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
...cheduler-task-sql/src/test/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTaskTest.java
Show resolved
Hide resolved
...cheduler-task-sql/src/test/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTaskTest.java
Show resolved
Hide resolved
...cheduler-task-sql/src/test/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTaskTest.java
Outdated
Show resolved
Hide resolved
OK, revert the unrelated changes. |
SbloodyS
left a comment
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.
LGTM
|



Purpose of the pull request
close #17701
Brief change log
handle duplicate column aliases in SQL result by appending column index suffix
Verify this pull request
This pull request is code cleanup without any test coverage.
(or)
This pull request is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(or)
Pull Request Notice
Pull Request Notice
If your pull request contains incompatible change, you should also add it to
docs/docs/en/guide/upgrade/incompatible.md