This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push: new ed4822fb21c [fix](nereids)column name should be case insensitive when selecting mv (#33009) ed4822fb21c is described below commit ed4822fb21c16403d536a684f29bc7f02e2eec5c Author: starocean999 <40539150+starocean...@users.noreply.github.com> AuthorDate: Fri Mar 29 16:03:44 2024 +0800 [fix](nereids)column name should be case insensitive when selecting mv (#33009) --- .../mv/AbstractSelectMaterializedIndexRule.java | 10 +++-- .../suites/nereids_p0/test_mv_select.groovy | 50 ++++++++++++++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/AbstractSelectMaterializedIndexRule.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/AbstractSelectMaterializedIndexRule.java index f535f6e2300..da73094e5a5 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/AbstractSelectMaterializedIndexRule.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/mv/AbstractSelectMaterializedIndexRule.java @@ -218,8 +218,10 @@ public abstract class AbstractSelectMaterializedIndexRule { Set<Expression> predicates, Map<ExprId, String> exprIdToName) { Map<Boolean, Set<String>> split = filterCanUsePrefixIndexAndSplitByEquality(predicates, exprIdToName); - Set<String> equalColNames = split.getOrDefault(true, ImmutableSet.of()); - Set<String> nonEqualColNames = split.getOrDefault(false, ImmutableSet.of()); + Set<String> equalColNames = split.getOrDefault(true, ImmutableSet.of()).stream() + .map(String::toLowerCase).collect(Collectors.toSet()); + Set<String> nonEqualColNames = split.getOrDefault(false, ImmutableSet.of()).stream() + .map(String::toLowerCase).collect(Collectors.toSet()); if (!(equalColNames.isEmpty() && nonEqualColNames.isEmpty())) { List<MaterializedIndex> matchingResult = matchKeyPrefixMost(scan.getTable(), candidate, @@ -357,9 +359,9 @@ public abstract class AbstractSelectMaterializedIndexRule { Set<String> nonEqualColNames) { int matchCount = 0; for (Column column : table.getSchemaByIndexId(index.getId())) { - if (equalColNames.contains(normalizeName(column.getNameWithoutMvPrefix()))) { + if (equalColNames.contains(normalizeName(column.getNameWithoutMvPrefix().toLowerCase()))) { matchCount++; - } else if (nonEqualColNames.contains(normalizeName(column.getNameWithoutMvPrefix()))) { + } else if (nonEqualColNames.contains(normalizeName(column.getNameWithoutMvPrefix().toLowerCase()))) { // un-equivalence predicate's columns can match only first column in index. matchCount++; break; diff --git a/regression-test/suites/nereids_p0/test_mv_select.groovy b/regression-test/suites/nereids_p0/test_mv_select.groovy index 096cfd50fab..4d7c93828e1 100644 --- a/regression-test/suites/nereids_p0/test_mv_select.groovy +++ b/regression-test/suites/nereids_p0/test_mv_select.groovy @@ -42,4 +42,54 @@ suite("test_mv_select") { group by Uid;""") contains "mv_test_table_t" } + + sql """drop table if exists SkuUniqDailyCounter""" + sql """CREATE TABLE `SkuUniqDailyCounter` ( + `Pd` bigint(20) NOT NULL, + `Dc` int(11) NOT NULL, + `Bc` bigint(20) NOT NULL, + `Fs` int(11) REPLACE NULL + ) ENGINE=OLAP + AGGREGATE KEY(`Pd`, `Dc`, `Bc`) + COMMENT 'OLAP' + DISTRIBUTED BY HASH(`Dc`) BUCKETS 8 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + );""" + def delta_time = 1000 + def wait_for_latest_op_on_table_finish = { table_name, OpTimeout -> + for(int t = delta_time; t <= OpTimeout; t += delta_time){ + alter_res = sql """SHOW ALTER TABLE COLUMN WHERE TableName = "${table_name}" ORDER BY CreateTime DESC LIMIT 1;""" + alter_res = alter_res.toString() + if(alter_res.contains("FINISHED")) { + sleep(10000) // wait change table state to normal + logger.info(table_name + " latest alter job finished, detail: " + alter_res) + break + } + useTime = t + sleep(delta_time) + } + assertTrue(useTime <= OpTimeout, "wait_for_latest_op_on_table_finish timeout") + } + sql """ALTER TABLE SkuUniqDailyCounter + ADD ROLLUP rollup_index_shopid( + Dc, + Bc, + Pd, + Fs + ); """ + wait_for_latest_op_on_table_finish("SkuUniqDailyCounter",60000); + sql """ALTER TABLE SkuUniqDailyCounter + ADD ROLLUP rollup_index_brandcid( + Bc, + Dc, + Pd, + Fs + );""" + wait_for_latest_op_on_table_finish("SkuUniqDailyCounter",60000); + + explain { + sql ("""select sum(Fs) Sales from SkuUniqDailyCounter where Bc=742502946 and Dc >=20240315 and Dc <= 20240328;""") + contains "rollup_index_brandcid" + } } \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org