forked from StarRocks/starrocks
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BugFix] Fix wrong result when query cache work with select node
The query cache does not normalize the select node during the normalize stage, which can lead to incorrect results if different predicates use the same digest. Signed-off-by: stdpain <[email protected]>
- Loading branch information
Showing
4 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-- name: test_query_cache_select_node | ||
CREATE TABLE `tarray` ( | ||
`id` int(4) NULL COMMENT "", | ||
`val` array<int> NULL COMMENT "" | ||
) ENGINE=OLAP | ||
DUPLICATE KEY(`id`) | ||
COMMENT "OLAP" | ||
DISTRIBUTED BY HASH(`id`) BUCKETS 2 | ||
PROPERTIES ( | ||
"compression" = "LZ4", | ||
"fast_schema_evolution" = "false", | ||
"replicated_storage" = "true", | ||
"replication_num" = "1" | ||
); | ||
-- result: | ||
-- !result | ||
insert into tarray SELECT generate_series, [generate_series % 4, generate_series%3] FROM TABLE(generate_series(1, 4096)); | ||
-- result: | ||
-- !result | ||
set enable_query_cache = true; | ||
-- result: | ||
-- !result | ||
set pipeline_dop=1; | ||
-- result: | ||
-- !result | ||
SELECT rule_id,COUNT(*) AS cnt FROM ( SELECT id,unnest AS rule_id FROM tarray, unnest(val) ) er WHERE rule_id IN (28,128,127) GROUP BY rule_id; | ||
-- result: | ||
-- !result | ||
SELECT rule_id,COUNT(*) AS cnt FROM ( SELECT id,unnest AS rule_id FROM tarray, unnest(val) ) er WHERE rule_id IN (1) GROUP BY rule_id; | ||
-- result: | ||
1 2390 | ||
-- !result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- name: test_query_cache_select_node | ||
CREATE TABLE `tarray` ( | ||
`id` int(4) NULL COMMENT "", | ||
`val` array<int> NULL COMMENT "" | ||
) ENGINE=OLAP | ||
DUPLICATE KEY(`id`) | ||
COMMENT "OLAP" | ||
DISTRIBUTED BY HASH(`id`) BUCKETS 2 | ||
PROPERTIES ( | ||
"compression" = "LZ4", | ||
"fast_schema_evolution" = "false", | ||
"replicated_storage" = "true", | ||
"replication_num" = "1" | ||
); | ||
|
||
insert into tarray SELECT generate_series, [generate_series % 4, generate_series%3] FROM TABLE(generate_series(1, 4096)); | ||
|
||
set enable_query_cache = true; | ||
set pipeline_dop=1; | ||
|
||
SELECT rule_id,COUNT(*) AS cnt FROM ( SELECT id,unnest AS rule_id FROM tarray, unnest(val) ) er WHERE rule_id IN (28,128,127) GROUP BY rule_id; | ||
SELECT rule_id,COUNT(*) AS cnt FROM ( SELECT id,unnest AS rule_id FROM tarray, unnest(val) ) er WHERE rule_id IN (1) GROUP BY rule_id; |