Skip to content

Commit 8d3329f

Browse files
committed
save
1 parent 7f7a072 commit 8d3329f

File tree

3 files changed

+86
-1
lines changed

3 files changed

+86
-1
lines changed

fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,11 @@ protected void toThrift(TPlanNode msg) {
15491549
if (sortLimit != -1) {
15501550
msg.olap_scan_node.setSortLimit(sortLimit);
15511551
}
1552-
msg.olap_scan_node.setKeyType(olapTable.getKeysType().toThrift());
1552+
if (selectedIndexId != -1) {
1553+
msg.olap_scan_node.setKeyType(olapTable.getIndexMetaByIndexId(selectedIndexId).getKeysType().toThrift());
1554+
} else {
1555+
msg.olap_scan_node.setKeyType(olapTable.getKeysType().toThrift());
1556+
}
15531557
String tableName = olapTable.getName();
15541558
if (selectedIndexId != -1) {
15551559
tableName = tableName + "(" + getSelectedIndexName() + ")";
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- This file is automatically generated. You should know what you did if you want to edit this
2+
-- !sql --
3+
100
4+
100
5+
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
suite("test_materialized_view_common_expr_push_down") {
19+
def baseTable = "test_base_tbl"
20+
def mvTable = "test_mv"
21+
22+
def getJobState = { tableName ->
23+
def jobStateResult = sql """ SHOW ALTER TABLE MATERIALIZED VIEW WHERE TableName='${tableName}' ORDER BY CreateTime DESC LIMIT 1; """
24+
return jobStateResult[0][8]
25+
}
26+
27+
sql """set enable_common_expr_pushdown = true"""
28+
29+
sql "DROP TABLE IF EXISTS ${baseTable}"
30+
sql """
31+
CREATE TABLE `${baseTable}` (
32+
`companyId` bigint NULL,
33+
`jobId` bigint NULL,
34+
`province` text NULL,
35+
`vCallerId` bigint NULL DEFAULT "0",
36+
`aCallerId` bigint NULL DEFAULT "-1"
37+
) ENGINE=OLAP
38+
DUPLICATE KEY(`companyId`)
39+
DISTRIBUTED BY HASH(`companyId`) BUCKETS 8
40+
PROPERTIES (
41+
"replication_allocation" = "tag.location.default: 1"
42+
);
43+
"""
44+
sql """
45+
CREATE materialized VIEW ${mvTable} AS SELECT
46+
companyId as company_id,
47+
jobId as job_id,
48+
province as p,
49+
vCallerId as v_caller_id,
50+
aCallerId as a_caller_id
51+
FROM ${baseTable}
52+
GROUP BY company_id, job_id, p, v_caller_id, a_caller_id;
53+
"""
54+
int max_try_secs = 60
55+
while (max_try_secs--) {
56+
String res = getJobState(baseTable)
57+
if (res == "FINISHED" || res == "CANCELLED") {
58+
assertEquals("FINISHED", res)
59+
sleep(3000)
60+
break
61+
} else {
62+
Thread.sleep(2000)
63+
if (max_try_secs < 1) {
64+
println "test timeout," + "state:" + res
65+
assertEquals("FINISHED",res)
66+
}
67+
}
68+
}
69+
70+
sql "insert into ${baseTable} values(100,100,'北京',3,3)"
71+
sql "insert into ${baseTable} values(100,100,'广东',3,3)"
72+
73+
qt_sql """ select mv_companyId from ${baseTable} index ${mvTable} where mv_vCallerId = 3 and if(`mv_aCallerId` is null,-1, `mv_aCallerId`) = 3 """
74+
75+
sql "DROP TABLE ${baseTable} FORCE;"
76+
}

0 commit comments

Comments
 (0)