starrocks icon indicating copy to clipboard operation
starrocks copied to clipboard

[BugFix] fix Duplicate key exception when get table statistics

Open kaijianding opened this issue 6 months ago • 5 comments

Why I'm doing:

CREATE TABLE `ptbl5` (
  `dt` date NULL COMMENT "",
  `id` int(11) NULL COMMENT "",
  `name` varchar(65533) NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`dt`, `id`, `name`)
PARTITION BY RANGE(`dt`)
(PARTITION p20250428 VALUES [("2025-04-28"), ("2025-04-29")),
PARTITION p20250429 VALUES [("2025-04-29"), ("2025-04-30")))
DISTRIBUTED BY HASH(`id`, `name`)
PROPERTIES (
"compression" = "LZ4",
"fast_schema_evolution" = "true",
"replicated_storage" = "true",
"replication_num" = "1"
);

insert into ptbl5 values("2025-04-29",1,'a');

-- ERROR 1064 (HY000): Duplicate key 5031178 (attempted merging values Optional.empty and Optional.empty)
select min(dt),max(dt) from ptbl5;

What I'm doing:

Fixes #issue

What type of PR is this:

  • [x] BugFix
  • [ ] Feature
  • [ ] Enhancement
  • [ ] Refactor
  • [ ] UT
  • [ ] Doc
  • [ ] Tool

Does this PR entail a change in behavior?

  • [ ] Yes, this PR will result in a change in behavior.
  • [x] No, this PR will not result in a change in behavior.

Bugfix cherry-pick branch check:

  • [x] I have checked the version labels which the pr will be auto-backported to the target branch
    • [x] 3.5
    • [x] 3.4
    • [x] 3.3

kaijianding avatar Jun 18 '25 13:06 kaijianding

please add test cases for it

kangkaisen avatar Jun 19 '25 07:06 kangkaisen

[Java-Extensions Incremental Coverage Report]

:white_check_mark: pass : 0 / 0 (0%)

github-actions[bot] avatar Jun 19 '25 09:06 github-actions[bot]

[FE Incremental Coverage Report]

:white_check_mark: pass : 5 / 5 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
:large_blue_circle: com/starrocks/sql/optimizer/statistics/CachedStatisticStorage.java 5 5 100.00% []

github-actions[bot] avatar Jun 19 '25 09:06 github-actions[bot]

[BE Incremental Coverage Report]

:white_check_mark: pass : 0 / 0 (0%)

github-actions[bot] avatar Jun 19 '25 09:06 github-actions[bot]

This PR is replaced by #60162 , close this one for now.

kevincai avatar Jun 25 '25 06:06 kevincai