qzsee opened a new issue, #16069: URL: https://github.com/apache/doris/issues/16069
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues. ### Version master ### What's Wrong? ```sql CREATE TABLE `a` ( `k1` int(11) NULL COMMENT "", `k2` bitmap BITMAP_UNION NULL COMMENT "", `k3` bitmap BITMAP_UNION NULL COMMENT "" ) ENGINE=OLAP AGGREGATE KEY(`k1`) COMMENT "OLAP" DISTRIBUTED BY HASH(`k1`) BUCKETS 10 PROPERTIES ( "replication_num" = "1", "in_memory" = "false", "storage_format" = "V2" ); CREATE TABLE `b` ( `k1` int(11) NULL COMMENT "" ) ENGINE=OLAP DUPLICATE KEY(`k1`) COMMENT "OLAP" DISTRIBUTED BY HASH(`k1`) BUCKETS 10 PROPERTIES ( "replication_num" = "1", "in_memory" = "false", "storage_format" = "V2" ); select count(distinct case when false then k2 when true then k3 end) as tmp from a where k1 in (select k1 from b group by k1); ERROR 1105 (HY000): errCode = 2, detailMessage = VSlotRef - invalid slot id 0 ``` #### For the selectList rewrite `count(distinct case when false then k2 when true then k3 end)` rewrite to `count(k3)` `count(k3)` information: ```java FunctionCallExpr - fnParams - isDistinct = true - exprs - CaseExpr - 0 = {BoolLiteral@6749} "BoolLiteral false" 1 = {SlotRef@6750} "SlotRef(k2)" 2 = {BoolLiteral@6751} "BoolLiteral(true)" 3 = {SlotRef@6752} "SlotRef(k3)" - child - SlotRef(k3) ``` #### For the Stmt rewrite It rewrite Selectlist again use `CountDistinctToBitmapOrHLLRule` rewrite `count(k3)` to `bitmap_union_count` `bitmap_union_count` information ```java FunctionCallExpr - fnParams - isDistinct = true - exprs - CaseExpr - 0 = {BoolLiteral@6749} "BoolLiteral false" 1 = {SlotRef@6750} "SlotRef(k2)" 2 = {BoolLiteral@6751} "BoolLiteral(true)" 3 = {SlotRef@6752} "SlotRef(k3)" - child - 0 = {BoolLiteral@6749} "BoolLiteral false" 1 = {SlotRef@6750} "SlotRef(k2)" 2 = {BoolLiteral@6751} "BoolLiteral(true)" 3 = {SlotRef@6752} "SlotRef(k3)" ``` `bitmap_union_count` FunctionCallExpr's child should `k3` instead of `CaseExpr` and child(1) `SlotRef(k2)` slot id and parent tuple id are last time outdate information. so Be could coredump. ### What You Expected? correct ### How to Reproduce? _No response_ ### Anything Else? _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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: commits-unsubscr...@doris.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org