Skip to content

Conversation

@njnu-seafish
Copy link
Contributor

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

@SbloodyS SbloodyS added the bug Something isn't working label Nov 18, 2025
@SbloodyS SbloodyS added this to the 3.4.0 milestone Nov 18, 2025
@SbloodyS SbloodyS changed the title [Fix-17701][SqlTask]handle duplicate column aliases in SQL result by appending column index suffix [Fix-17701][SqlTask] handle duplicate column aliases in SQL result by appending column index suffix Nov 19, 2025
Copy link
Member

@SbloodyS SbloodyS left a 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

@njnu-seafish
Copy link
Contributor Author

Please add some ut to test it. @njnu-seafish

ok

Copy link
Member

@SbloodyS SbloodyS left a 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.

@SbloodyS SbloodyS requested a review from Copilot November 26, 2025 06:07
Copilot finished reviewing on behalf of SbloodyS November 26, 2025 06:10
Copy link

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.

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.

@njnu-seafish
Copy link
Contributor Author

Please don't directly use code generated by AI.

OK, revert the unrelated changes.

Copy link
Member

@SbloodyS SbloodyS left a comment

Choose a reason for hiding this comment

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

LGTM

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 1, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] [SqlTask] When field names are duplicated in a query statement, the result set suffers from name collision, causing values to overwrite each other

2 participants