Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2828,6 +2828,9 @@ private void assignScanRanges(PlanFragmentId fragmentId, int parallelExecInstanc
//the scan instance num should not larger than the tablets num
expectedInstanceNum = Math.min(scanRange.size(), parallelExecInstanceNum);
}
if (params.fragment != null && params.fragment.queryCacheParam != null) {
expectedInstanceNum = scanRange.size();
}
// 2. split how many scanRange one instance should scan
List<List<Pair<Integer, Map<Integer, List<TScanRangeParams>>>>> perInstanceScanRanges
= ListUtil.splitBySize(scanRange, expectedInstanceNum);
Expand Down
29 changes: 29 additions & 0 deletions regression-test/data/query_p0/cache/query_cache.out
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,32 @@
0 \N \N \N \N
1 6 6 6 6

-- !query_cache1 --

-- !query_cache2 --
0 0 0
1 1 1
2 2 2

-- !query_cache3 --

-- !query_cache4 --
0 0 0
1 1 1
2 2 2

-- !query_cache5 --

-- !query_cache6 --
0 0 0
1 1 1
2 2 2

-- !query_cache7 --
\N \N \N 0 \N
6 6 6 1 6

-- !query_cache8 --
0 \N \N \N \N
1 6 6 6 6

48 changes: 29 additions & 19 deletions regression-test/suites/query_p0/cache/query_cache.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ import java.util.stream.Collectors
suite("query_cache") {
def tableName = "table_3_undef_partitions2_keys3_properties4_distributed_by53"

sql """ DROP TABLE IF EXISTS ${tableName} """
sql """
def test = {
sql "set enable_query_cache=false"

sql """ DROP TABLE IF EXISTS ${tableName} """
sql """
CREATE TABLE ${tableName} (
`pk` int NULL,
`col_varchar_10__undef_signed` varchar(10) NULL,
Expand All @@ -45,16 +48,16 @@ suite("query_cache") {
)
"""

sql """
sql """
INSERT INTO ${tableName}(pk, col_varchar_10__undef_signed, col_int_undef_signed, col_varchar_1024__undef_signed)
VALUES
(0, "mean", null, "p"),
(1, "is", 6, "what"),
(2, "one", null, "e")
"""

// First complex query - Run without cache
order_qt_query_cache1 """
// First complex query - Run without cache
order_qt_query_cache1 """
SELECT
MIN(`pk`) AS field1,
MAX(`pk`) AS field2,
Expand All @@ -78,8 +81,8 @@ suite("query_cache") {
GROUP BY field3
"""

// Simple query - Run without cache
order_qt_query_cache2 """
// Simple query - Run without cache
order_qt_query_cache2 """
SELECT
MIN(`pk`) AS field1,
MAX(`pk`) AS field2,
Expand All @@ -88,11 +91,11 @@ suite("query_cache") {
GROUP BY field3
"""

// Enable query cache
sql "set enable_query_cache=true"
// Enable query cache
sql "set enable_query_cache=true"

// Run the same complex query with cache enabled
order_qt_query_cache3 """
// Run the same complex query with cache enabled
order_qt_query_cache3 """
SELECT
MIN(`pk`) AS field1,
MAX(`pk`) AS field2,
Expand All @@ -116,8 +119,8 @@ suite("query_cache") {
GROUP BY field3
"""

// Run the same simple query with cache enabled
order_qt_query_cache4 """
// Run the same simple query with cache enabled
order_qt_query_cache4 """
SELECT
MIN(`pk`) AS field1,
MAX(`pk`) AS field2,
Expand All @@ -126,8 +129,8 @@ suite("query_cache") {
GROUP BY field3
"""

// Run both queries again to test cache hit
order_qt_query_cache5 """
// Run both queries again to test cache hit
order_qt_query_cache5 """
SELECT
MIN(`pk`) AS field1,
MAX(`pk`) AS field2,
Expand All @@ -151,7 +154,7 @@ suite("query_cache") {
GROUP BY field3
"""

order_qt_query_cache6 """
order_qt_query_cache6 """
SELECT
MIN(`pk`) AS field1,
MAX(`pk`) AS field2,
Expand All @@ -160,7 +163,7 @@ suite("query_cache") {
GROUP BY field3
"""

order_qt_query_cache7 """
order_qt_query_cache7 """
SELECT
col_int_undef_signed,
MIN(`col_int_undef_signed`) AS field1,
Expand All @@ -171,8 +174,8 @@ suite("query_cache") {
GROUP BY col_int_undef_signed
"""

// reorder the order_qt_query_cache7 select list to test the cache hit
order_qt_query_cache8 """
// reorder the order_qt_query_cache7 select list to test the cache hit
order_qt_query_cache8 """
SELECT
COUNT(`col_int_undef_signed`) AS field3, -- Count of col_int_undef_signed (Original field3)
col_int_undef_signed, -- The original unsigned integer column (Original col_int_undef_signed)
Expand All @@ -182,4 +185,11 @@ suite("query_cache") {
FROM ${tableName}
GROUP BY col_int_undef_signed;
"""
}

sql "set enable_nereids_distribute_planner=false"
test()

sql "set enable_nereids_distribute_planner=true"
test()
}
Loading