Mryange opened a new pull request, #63713:
URL: https://github.com/apache/doris/pull/63713
### What problem does this PR solve?
Problem Summary:
Casting a JSON string with duplicated object keys to MAP kept all duplicated
entries because the string-to-complex cast path returned the generic wrapper
directly and skipped ColumnMap::deduplicate_keys(). This made string-to-map
casts inconsistent with MAP constructor semantics where the last value wins.
Reproduction SQL:
```sql
SELECT CAST('{"a":1,"a":2}' AS MAP<STRING,INT>);
SELECT size(CAST('{"a":1,"a":2}' AS MAP<STRING,INT>));
SELECT element_at(CAST('{"a":1,"a":2}' AS MAP<STRING,INT>), 'a');
SELECT map('a',1,'a',2);
SELECT size(map('a',1,'a',2));
SELECT element_at(map('a',1,'a',2), 'a');
```
Before this fix:
```text
{"a":1, "a":2}
2
1
{"a":2}
1
2
```
After this fix:
```text
{"a":2}
1
2
{"a":2}
1
2
```
This change wraps the string-to-map cast path with a map-key deduplication
step so duplicated keys are normalized after parsing from string. It also adds
regression coverage for the cast result, size, and element_at behavior on
duplicated keys.
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should
merge into -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]