This is an automated email from the ASF dual-hosted git repository. panxiaolei pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new cec983b7ef [Chore](materialized-view) forbiden create mv with where clause contained aggregate column (#18168) cec983b7ef is described below commit cec983b7ef731bd48fc3aceb77cb4c2dd34f6be7 Author: Pxl <pxl...@qq.com> AuthorDate: Thu Mar 30 13:03:03 2023 +0800 [Chore](materialized-view) forbiden create mv with where clause contained aggregate column (#18168) forbiden create mv with where clause contained aggregate column create table a_table( k1 int null, k2 int not null, k3 bigint null, k4 bigint sum null, k5 bitmap bitmap_union null, k6 hll hll_union null ) aggregate key (k1,k2,k3) distributed BY hash(k1) buckets 3 properties("replication_num" = "1"); create materialized view where_1 as select k1,k4 from a_table where k4 =1; // invalid, mv on agg table need group by create materialized view where_2 as select k1,sum(k4) from a_table where k4 =1 group by k1; // invalid, k4 is agg column create materialized view where_2 as select k1,sum(k4) from a_table where k1+k4 =1 group by k1; // invalid, k4 is agg column --- .../doris/analysis/CreateMaterializedViewStmt.java | 5 ++++ .../{ => agg_invalid}/agg_invalid.groovy | 7 +---- .../where_invalid.groovy} | 32 +++++++++++----------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java index bbab202051..de9caed75f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java @@ -165,6 +165,11 @@ public class CreateMaterializedViewStmt extends DdlStmt { analyzeSelectClause(analyzer); analyzeFromClause(); if (selectStmt.getWhereClause() != null) { + if (!isReplay && selectStmt.getWhereClause().hasAggregateSlot()) { + throw new AnalysisException( + "The where clause contained aggregate column is not supported, expr:" + + selectStmt.getWhereClause().toSql()); + } whereClauseItem = new MVColumnItem(selectStmt.getWhereClause()); } if (selectStmt.getHavingPred() != null) { diff --git a/regression-test/suites/mv_p0/test_mv_useless/agg_invalid.groovy b/regression-test/suites/mv_p0/test_mv_useless/agg_invalid/agg_invalid.groovy similarity index 85% copy from regression-test/suites/mv_p0/test_mv_useless/agg_invalid.groovy copy to regression-test/suites/mv_p0/test_mv_useless/agg_invalid/agg_invalid.groovy index f4702769ca..bdf7a567be 100644 --- a/regression-test/suites/mv_p0/test_mv_useless/agg_invalid.groovy +++ b/regression-test/suites/mv_p0/test_mv_useless/agg_invalid/agg_invalid.groovy @@ -16,11 +16,6 @@ // under the License. suite ("agg_invalid") { - def testTable = "test_agg_mv_useless_table" - def getJobState = { tableName -> - def jobStateResult = sql """ SHOW ALTER TABLE MATERIALIZED VIEW WHERE TableName='${testTable}' ORDER BY CreateTime DESC LIMIT 1; """ - return jobStateResult[0][8] - } sql """drop table if exists t1;""" sql """ @@ -42,7 +37,7 @@ suite ("agg_invalid") { exception null } - test { + test { sql "CREATE MATERIALIZED VIEW mv_4 AS SELECT p1, SUM(abs(v1)) FROM t1 GROUP BY p1;" exception "errCode = 2," } diff --git a/regression-test/suites/mv_p0/test_mv_useless/agg_invalid.groovy b/regression-test/suites/mv_p0/test_mv_useless/where_invalid/where_invalid.groovy similarity index 51% rename from regression-test/suites/mv_p0/test_mv_useless/agg_invalid.groovy rename to regression-test/suites/mv_p0/test_mv_useless/where_invalid/where_invalid.groovy index f4702769ca..f0d96a773f 100644 --- a/regression-test/suites/mv_p0/test_mv_useless/agg_invalid.groovy +++ b/regression-test/suites/mv_p0/test_mv_useless/where_invalid/where_invalid.groovy @@ -15,35 +15,35 @@ // specific language governing permissions and limitations // under the License. -suite ("agg_invalid") { - def testTable = "test_agg_mv_useless_table" - def getJobState = { tableName -> - def jobStateResult = sql """ SHOW ALTER TABLE MATERIALIZED VIEW WHERE TableName='${testTable}' ORDER BY CreateTime DESC LIMIT 1; """ - return jobStateResult[0][8] - } - sql """drop table if exists t1;""" +suite ("where_invalid") { + sql """drop table if exists a_table;""" sql """ - CREATE TABLE t1 ( p1 INT, p2 INT, p3 INT, v1 INT SUM, v2 INT MAX, v3 INT MIN ) AGGREGATE KEY (p1, p2, p3) DISTRIBUTED BY HASH (p1) BUCKETS 1 PROPERTIES ('replication_num' = '1'); + create table a_table( + k1 int null, + k2 int not null, + k3 bigint null, + k4 bigint sum null, + k5 bitmap bitmap_union null, + k6 hll hll_union null + ) + aggregate key (k1,k2,k3) + distributed BY hash(k1) buckets 3 + properties("replication_num" = "1"); """ test { - sql "CREATE MATERIALIZED VIEW mv_1 AS SELECT p1, SUM(v3) FROM t1 GROUP BY p1;" + sql "create materialized view where_1 as select k1,k4 from a_table where k4 =1;" exception "errCode = 2," } test { - sql "CREATE MATERIALIZED VIEW mv_2 AS SELECT p1, MIN(v3+v3) FROM t1 GROUP BY p1;" + sql "create materialized view where_2 as select k1,sum(k4) from a_table where k4 =1 group by k1;" exception "errCode = 2," } test { - sql "CREATE MATERIALIZED VIEW mv_3 AS SELECT p1, SUM(v1) FROM t1 GROUP BY p1;" - exception null - } - - test { - sql "CREATE MATERIALIZED VIEW mv_4 AS SELECT p1, SUM(abs(v1)) FROM t1 GROUP BY p1;" + sql "create materialized view where_2 as select k1,sum(k4) from a_table where k1+k4 =1 group by k1;" exception "errCode = 2," } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org