You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2021/12/31 08:09:49 UTC

[incubator-doris] branch master updated: [fix](materialized-view) forbidden create materialized view with distinct (#7494)

This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new d6cc3fd  [fix](materialized-view) forbidden create materialized view with distinct (#7494)
d6cc3fd is described below

commit d6cc3fdf03f2e11f88dae5bd8f7a1b00553fd138
Author: xuzifu666 <xu...@zepp.com>
AuthorDate: Fri Dec 31 16:08:37 2021 +0800

    [fix](materialized-view) forbidden create materialized view with distinct (#7494)
---
 .../java/org/apache/doris/alter/RollupJobV2.java   |  1 +
 .../doris/analysis/CreateMaterializedViewStmt.java | 25 ++++--
 .../doris/analysis/MVColumnBitmapUnionPattern.java |  3 +
 .../doris/analysis/MVColumnHLLUnionPattern.java    |  3 +
 .../doris/analysis/MVColumnOneChildPattern.java    |  3 +
 .../apache/doris/catalog/AggregateFunction.java    | 32 ++++++++
 .../doris/catalog/MaterializedIndexMeta.java       |  1 +
 .../analysis/CreateMaterializedViewStmtTest.java   | 96 ++++++++++++++++++++--
 .../analysis/MVColumnBitmapUnionPatternTest.java   | 22 +++--
 .../analysis/MVColumnHLLUnionPatternTest.java      | 22 +++--
 .../analysis/MVColumnOneChildPatternTest.java      | 17 ++--
 11 files changed, 191 insertions(+), 34 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java b/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java
index 28fbd79..e344c8f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java
@@ -809,6 +809,7 @@ public class RollupJobV2 extends AlterJobV2 implements GsonPostProcessable {
         CreateMaterializedViewStmt stmt = null;
         try {
             stmt = (CreateMaterializedViewStmt) SqlParserUtils.getStmt(parser, origStmt.idx);
+            stmt.setIsReplay(true);
             stmt.analyze(analyzer);
         } catch (Exception e) {
             // Under normal circumstances, the stmt will not fail to analyze.
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 f29daba..4200533 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
@@ -88,6 +88,8 @@ public class CreateMaterializedViewStmt extends DdlStmt {
     private String baseIndexName;
     private String dbName;
     private KeysType mvKeysType = KeysType.DUP_KEYS;
+    //if process is replaying log, isReplay is true, otherwise is false, avoid replay process error report, only in Rollup or MaterializedIndexMeta is true
+    private boolean isReplay = false;
 
     public CreateMaterializedViewStmt(String mvName, SelectStmt selectStmt, Map<String, String> properties) {
         this.mvName = mvName;
@@ -95,6 +97,10 @@ public class CreateMaterializedViewStmt extends DdlStmt {
         this.properties = properties;
     }
 
+    public void setIsReplay(boolean isReplay) {
+        this.isReplay = isReplay;
+    }
+
     public String getMVName() {
         return mvName;
     }
@@ -193,14 +199,17 @@ public class CreateMaterializedViewStmt extends DdlStmt {
                 // Function must match pattern.
                 FunctionCallExpr functionCallExpr = (FunctionCallExpr) selectListItemExpr;
                 String functionName = functionCallExpr.getFnName().getFunction();
-                MVColumnPattern mvColumnPattern = FN_NAME_TO_PATTERN.get(functionName.toLowerCase());
-                if (mvColumnPattern == null) {
-                    throw new AnalysisException(
-                            "Materialized view does not support this function:" + functionCallExpr.toSqlImpl());
-                }
-                if (!mvColumnPattern.match(functionCallExpr)) {
-                    throw new AnalysisException(
-                            "The function " + functionName + " must match pattern:" + mvColumnPattern.toString());
+                // current version not support count(distinct) function in creating materialized view
+                if (!isReplay) {
+                    MVColumnPattern mvColumnPattern = FN_NAME_TO_PATTERN.get(functionName.toLowerCase());
+                    if (mvColumnPattern == null) {
+                        throw new AnalysisException(
+                                "Materialized view does not support this function:" + functionCallExpr.toSqlImpl());
+                    }
+                    if (!mvColumnPattern.match(functionCallExpr)) {
+                        throw new AnalysisException(
+                                "The function " + functionName + " must match pattern:" + mvColumnPattern.toString());
+                    }
                 }
                 // check duplicate column
                 List<SlotRef> slots = new ArrayList<>();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnBitmapUnionPattern.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnBitmapUnionPattern.java
index 68f9276..45bf9948 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnBitmapUnionPattern.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnBitmapUnionPattern.java
@@ -28,6 +28,9 @@ public class MVColumnBitmapUnionPattern implements MVColumnPattern {
             return false;
         }
         FunctionCallExpr fnExpr = (FunctionCallExpr) expr;
+        if (fnExpr.isDistinct()) {
+            return false;
+        }
         String fnNameString = fnExpr.getFnName().getFunction();
         if (!fnNameString.equalsIgnoreCase(FunctionSet.BITMAP_UNION)) {
             return false;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnHLLUnionPattern.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnHLLUnionPattern.java
index 7d58b2c..f6f6c73 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnHLLUnionPattern.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnHLLUnionPattern.java
@@ -28,6 +28,9 @@ public class MVColumnHLLUnionPattern implements MVColumnPattern {
             return false;
         }
         FunctionCallExpr fnExpr = (FunctionCallExpr) expr;
+        if (fnExpr.isDistinct()) {
+            return false;
+        }
         String fnNameString = fnExpr.getFnName().getFunction();
         if (!fnNameString.equalsIgnoreCase(FunctionSet.HLL_UNION)){
             return false;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnOneChildPattern.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnOneChildPattern.java
index ed50c91..1bdf17a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnOneChildPattern.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/MVColumnOneChildPattern.java
@@ -31,6 +31,9 @@ public class MVColumnOneChildPattern implements MVColumnPattern {
             return false;
         }
         FunctionCallExpr functionCallExpr = (FunctionCallExpr) expr;
+        if (functionCallExpr.isDistinct()) {
+            return false;
+        }
         String exprFnName = functionCallExpr.getFnName().getFunction();
         if (!exprFnName.equalsIgnoreCase(functionName)) {
             return false;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/AggregateFunction.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/AggregateFunction.java
index 04fcff2..05fae0c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/AggregateFunction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/AggregateFunction.java
@@ -103,6 +103,38 @@ public class AggregateFunction extends Function {
     }
 
     public AggregateFunction(FunctionName fnName, List<Type> argTypes,
+                             Type retType, Type intermediateType, boolean hasVarArgs) {
+        super(fnName, argTypes, retType, hasVarArgs);
+        this.intermediateType = (intermediateType != null && intermediateType.equals(retType)) ? null : intermediateType;
+        ignoresDistinct = false;
+        isAnalyticFn = false;
+        isAggregateFn = true;
+        returnsNonNullOnEmpty = false;
+    }
+
+    public static AggregateFunction createBuiltin(String name,
+                                                  List<Type> argTypes, Type retType, Type intermediateType,
+                                                  boolean ignoresDistinct,
+                                                  boolean isAnalyticFn,
+                                                  boolean returnsNonNullOnEmpty) {
+        return createBuiltin(name, argTypes, retType, intermediateType, false, ignoresDistinct, isAnalyticFn, returnsNonNullOnEmpty);
+    }
+
+    public static AggregateFunction createBuiltin(String name,
+                                                  List<Type> argTypes, Type retType, Type intermediateType,
+                                                  boolean hasVarArgs, boolean ignoresDistinct,
+                                                  boolean isAnalyticFn,
+                                                  boolean returnsNonNullOnEmpty) {
+        AggregateFunction fn = new AggregateFunction(new FunctionName(name), argTypes, retType, intermediateType, hasVarArgs);
+        fn.setBinaryType(TFunctionBinaryType.BUILTIN);
+        fn.ignoresDistinct = ignoresDistinct;
+        fn.isAnalyticFn = isAnalyticFn;
+        fn.isAggregateFn = true;
+        fn.returnsNonNullOnEmpty = returnsNonNullOnEmpty;
+        return fn;
+    }
+
+    public AggregateFunction(FunctionName fnName, List<Type> argTypes,
                              Type retType, Type intermediateType,
                              HdfsURI location, String updateFnSymbol, String initFnSymbol,
                              String serializeFnSymbol, String mergeFnSymbol, String getValueFnSymbol,
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndexMeta.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndexMeta.java
index c236554..d485f12 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndexMeta.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndexMeta.java
@@ -188,6 +188,7 @@ public class MaterializedIndexMeta implements Writable, GsonPostProcessable {
         CreateMaterializedViewStmt stmt;
         try {
             stmt = (CreateMaterializedViewStmt) SqlParserUtils.getStmt(parser, defineStmt.idx);
+            stmt.setIsReplay(true);
             Map<String, Expr> columnNameToDefineExpr = stmt.parseDefineExprWithoutAnalyze();
             setColumnsDefineExpr(columnNameToDefineExpr);
         } catch (Exception e) {
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateMaterializedViewStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateMaterializedViewStmtTest.java
index 7127aee..50932d5 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateMaterializedViewStmtTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateMaterializedViewStmtTest.java
@@ -17,12 +17,15 @@
 
 package org.apache.doris.analysis;
 
+import org.apache.doris.catalog.AggregateFunction;
 import org.apache.doris.catalog.AggregateType;
 import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.FunctionSet;
 import org.apache.doris.catalog.KeysType;
 import org.apache.doris.catalog.PrimitiveType;
 import org.apache.doris.catalog.ScalarType;
 import org.apache.doris.catalog.Type;
+import org.apache.doris.common.AnalysisException;
 import org.apache.doris.common.Config;
 import org.apache.doris.common.UserException;
 import org.apache.doris.common.jmockit.Deencapsulation;
@@ -81,9 +84,76 @@ public class CreateMaterializedViewStmtTest {
     }
 
     @Test
+    public void testCountDistinct(@Injectable SlotRef slotRef, @Injectable ArithmeticExpr arithmeticExpr,
+                                  @Injectable SelectStmt selectStmt, @Injectable Column column,
+                                  @Injectable TableRef tableRef,
+                                  @Injectable SlotDescriptor slotDescriptor) throws UserException {
+        SelectList selectList = new SelectList();
+        SelectListItem selectListItem = new SelectListItem(slotRef, null);
+        selectList.addItem(selectListItem);
+
+        TableName tableName = new TableName("db", "table");
+        SlotRef slotRef2 = new SlotRef(tableName, "v1");
+        List<Expr> fnChildren = Lists.newArrayList(slotRef2);
+        Deencapsulation.setField(slotRef2, "desc", slotDescriptor);
+        FunctionParams functionParams = new FunctionParams(true, fnChildren);
+        FunctionCallExpr functionCallExpr = new FunctionCallExpr(FunctionSet.COUNT, functionParams);
+        functionCallExpr.setFn(AggregateFunction.createBuiltin(FunctionSet.COUNT,
+                new ArrayList<>(), Type.BIGINT, Type.BIGINT, false, true, true));
+        SelectListItem selectListItem2 = new SelectListItem(functionCallExpr, null);
+        selectList.addItem(selectListItem2);
+
+        new Expectations() {
+            {
+                analyzer.getClusterName();
+                result = "default";
+                selectStmt.analyze(analyzer);
+                selectStmt.getSelectList();
+                result = selectList;
+                arithmeticExpr.toString();
+                result = "a+b";
+                slotRef.getColumnName();
+                result = "k1";
+                selectStmt.getWhereClause();
+                minTimes = 0;
+                result = null;
+                selectStmt.getHavingPred();
+                minTimes = 0;
+                result = null;
+                selectStmt.getTableRefs();
+                minTimes = 0;
+                result = Lists.newArrayList(tableRef);
+                slotDescriptor.getColumn();
+                minTimes = 0;
+                result = column;
+                selectStmt.getLimit();
+                minTimes = 0;
+                result = -1;
+                column.getType();
+                minTimes = 0;
+                result = Type.INT;
+                slotRef.getType();
+                result = Type.INT;
+            }
+        };
+        CreateMaterializedViewStmt createMaterializedViewStmt =
+                new CreateMaterializedViewStmt("test", selectStmt, null);
+        try {
+            createMaterializedViewStmt.analyze(analyzer);
+            Assert.fail();
+        } catch (AnalysisException e) {
+            Assert.assertTrue(
+                    e.getMessage().contains("The function count must match pattern:count(column)"));
+            System.out.print(e.getMessage());
+        }
+    }
+
+    @Test
     public void testAggregateWithFunctionColumnInSelectClause(@Injectable ArithmeticExpr arithmeticExpr,
-                                                              @Injectable SelectStmt selectStmt) throws UserException {
+                                                              @Injectable SelectStmt selectStmt,
+                                                              @Injectable AggregateFunction aggregateFunction) throws UserException {
         FunctionCallExpr functionCallExpr = new FunctionCallExpr("sum", Lists.newArrayList(arithmeticExpr));
+        Deencapsulation.setField(functionCallExpr, "fn", aggregateFunction);
         SelectList selectList = new SelectList();
         SelectListItem selectListItem = new SelectListItem(functionCallExpr, null);
         selectList.addItem(selectListItem);
@@ -256,7 +326,8 @@ public class CreateMaterializedViewStmtTest {
                                            @Injectable TableRef tableRef,
                                            @Injectable SelectStmt selectStmt,
                                            @Injectable Column column2,
-                                           @Injectable SlotDescriptor slotDescriptor) throws UserException {
+                                           @Injectable SlotDescriptor slotDescriptor,
+                                           @Injectable AggregateFunction aggregateFunction) throws UserException {
         SelectList selectList = new SelectList();
         SelectListItem selectListItem1 = new SelectListItem(slotRef1, null);
         selectList.addItem(selectListItem1);
@@ -265,6 +336,7 @@ public class CreateMaterializedViewStmtTest {
         Deencapsulation.setField(slotRef2, "desc", slotDescriptor);
         List<Expr> fnChildren = Lists.newArrayList(slotRef2);
         FunctionCallExpr functionCallExpr = new FunctionCallExpr("sum", fnChildren);
+        Deencapsulation.setField(functionCallExpr, "fn", aggregateFunction);
         SelectListItem selectListItem2 = new SelectListItem(functionCallExpr, null);
         selectList.addItem(selectListItem2);
         OrderByElement orderByElement1 = new OrderByElement(functionCallExpr, false, false);
@@ -304,7 +376,7 @@ public class CreateMaterializedViewStmtTest {
     }
 
     @Test
-    public void testDuplicateColumn(@Injectable SelectStmt selectStmt) throws UserException {
+    public void testDuplicateColumn(@Injectable SelectStmt selectStmt, @Injectable AggregateFunction aggregateFunction) throws UserException {
         SelectList selectList = new SelectList();
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef1 = new SlotRef(tableName, "k1");
@@ -312,6 +384,7 @@ public class CreateMaterializedViewStmtTest {
         selectList.addItem(selectListItem1);
         List<Expr> fnChildren = Lists.newArrayList(slotRef1);
         FunctionCallExpr functionCallExpr = new FunctionCallExpr("sum", fnChildren);
+        Deencapsulation.setField(functionCallExpr, "fn", aggregateFunction);
         SelectListItem selectListItem2 = new SelectListItem(functionCallExpr, null);
         selectList.addItem(selectListItem2);
 
@@ -337,7 +410,8 @@ public class CreateMaterializedViewStmtTest {
     public void testDuplicateColumn1(@Injectable SlotRef slotRef1,
                                      @Injectable SelectStmt selectStmt,
                                      @Injectable Column column2,
-                                     @Injectable SlotDescriptor slotDescriptor) throws UserException {
+                                     @Injectable SlotDescriptor slotDescriptor,
+                                     @Injectable AggregateFunction aggregateFunction) throws UserException {
         SelectList selectList = new SelectList();
         SelectListItem selectListItem1 = new SelectListItem(slotRef1, null);
         selectList.addItem(selectListItem1);
@@ -346,9 +420,11 @@ public class CreateMaterializedViewStmtTest {
         Deencapsulation.setField(slotRef2, "desc", slotDescriptor);
         List<Expr> fn1Children = Lists.newArrayList(slotRef2);
         FunctionCallExpr functionCallExpr1 = new FunctionCallExpr("sum", fn1Children);
+        Deencapsulation.setField(functionCallExpr1, "fn", aggregateFunction);
         SelectListItem selectListItem2 = new SelectListItem(functionCallExpr1, null);
         selectList.addItem(selectListItem2);
         FunctionCallExpr functionCallExpr2 = new FunctionCallExpr("max", fn1Children);
+        Deencapsulation.setField(functionCallExpr2, "fn", aggregateFunction);
         SelectListItem selectListItem3 = new SelectListItem(functionCallExpr2, null);
         selectList.addItem(selectListItem3);
 
@@ -382,7 +458,8 @@ public class CreateMaterializedViewStmtTest {
                                                          @Injectable TableRef tableRef,
                                                          @Injectable SelectStmt selectStmt,
                                                          @Injectable Column column3,
-                                                         @Injectable SlotDescriptor slotDescriptor) throws UserException {
+                                                         @Injectable SlotDescriptor slotDescriptor,
+                                                         @Injectable AggregateFunction aggregateFunction) throws UserException {
         SelectList selectList = new SelectList();
         SelectListItem selectListItem1 = new SelectListItem(slotRef1, null);
         selectList.addItem(selectListItem1);
@@ -393,6 +470,7 @@ public class CreateMaterializedViewStmtTest {
         Deencapsulation.setField(functionChild0, "desc", slotDescriptor);
         List<Expr> fn1Children = Lists.newArrayList(functionChild0);
         FunctionCallExpr functionCallExpr = new FunctionCallExpr("sum", fn1Children);
+        Deencapsulation.setField(functionCallExpr, "fn", aggregateFunction);
         SelectListItem selectListItem3 = new SelectListItem(functionCallExpr, null);
         selectList.addItem(selectListItem3);
         OrderByElement orderByElement1 = new OrderByElement(slotRef1, false, false);
@@ -441,7 +519,8 @@ public class CreateMaterializedViewStmtTest {
                                             @Injectable SelectStmt selectStmt,
                                             @Injectable AggregateInfo aggregateInfo,
                                             @Injectable Column column5,
-                                            @Injectable SlotDescriptor slotDescriptor) throws UserException {
+                                            @Injectable SlotDescriptor slotDescriptor,
+                                            @Injectable AggregateFunction aggregateFunction) throws UserException {
         SelectList selectList = new SelectList();
         SelectListItem selectListItem1 = new SelectListItem(slotRef1, null);
         selectList.addItem(selectListItem1);
@@ -457,6 +536,7 @@ public class CreateMaterializedViewStmtTest {
         Deencapsulation.setField(functionChild0, "desc", slotDescriptor);
         List<Expr> fn1Children = Lists.newArrayList(functionChild0);
         FunctionCallExpr functionCallExpr = new FunctionCallExpr("sum", fn1Children);
+        Deencapsulation.setField(functionCallExpr, "fn", aggregateFunction);
         SelectListItem selectListItem5 = new SelectListItem(functionCallExpr, null);
         selectList.addItem(selectListItem5);
         final String columnName1 = "k1";
@@ -939,7 +1019,8 @@ public class CreateMaterializedViewStmtTest {
                               @Injectable SelectStmt selectStmt,
                               @Injectable AggregateInfo aggregateInfo,
                               @Injectable Column column1,
-                              @Injectable SlotDescriptor slotDescriptor) throws UserException {
+                              @Injectable SlotDescriptor slotDescriptor,
+                              @Injectable AggregateFunction aggregateFunction) throws UserException {
         SelectList selectList = new SelectList();
         SelectListItem selectListItem1 = new SelectListItem(slotRef1, null);
         selectList.addItem(selectListItem1);
@@ -951,6 +1032,7 @@ public class CreateMaterializedViewStmtTest {
         Deencapsulation.setField(slotRef, "desc", slotDescriptor);
         List<Expr> children = Lists.newArrayList(slotRef);
         FunctionCallExpr functionCallExpr = new FunctionCallExpr("sum", children);
+        Deencapsulation.setField(functionCallExpr, "fn", aggregateFunction);
         SelectListItem selectListItem3 = new SelectListItem(functionCallExpr, null);
         selectList.addItem(selectListItem3);
         OrderByElement orderByElement1 = new OrderByElement(slotRef1, false, false);
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/MVColumnBitmapUnionPatternTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/MVColumnBitmapUnionPatternTest.java
index 4b78903..5bf10bc 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/MVColumnBitmapUnionPatternTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/MVColumnBitmapUnionPatternTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.doris.analysis;
 
+import org.apache.doris.catalog.AggregateFunction;
 import org.apache.doris.catalog.Column;
 import org.apache.doris.catalog.FunctionSet;
 import org.apache.doris.catalog.Type;
@@ -35,7 +36,7 @@ import mockit.Injectable;
 public class MVColumnBitmapUnionPatternTest {
 
     @Test
-    public void testCorrectExpr1() {
+    public void testCorrectExpr1(@Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef = new SlotRef(tableName, "c1");
         Deencapsulation.setField(slotRef, "type", Type.INT);
@@ -45,12 +46,13 @@ public class MVColumnBitmapUnionPatternTest {
         List<Expr> params = Lists.newArrayList();
         params.add(child0);
         FunctionCallExpr expr = new FunctionCallExpr(FunctionSet.BITMAP_UNION, params);
+        Deencapsulation.setField(expr, "fn", aggregateFunction);
         MVColumnBitmapUnionPattern pattern = new MVColumnBitmapUnionPattern();
         Assert.assertTrue(pattern.match(expr));
     }
 
     @Test
-    public void testCorrectExpr2(@Injectable CastExpr castExpr) {
+    public void testCorrectExpr2(@Injectable CastExpr castExpr, @Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef = new SlotRef(tableName, "c1");
         Deencapsulation.setField(slotRef, "type", Type.INT);
@@ -66,12 +68,13 @@ public class MVColumnBitmapUnionPatternTest {
         List<Expr> params = Lists.newArrayList();
         params.add(child0);
         FunctionCallExpr expr = new FunctionCallExpr(FunctionSet.BITMAP_UNION, params);
+        Deencapsulation.setField(expr, "fn", aggregateFunction);
         MVColumnBitmapUnionPattern pattern = new MVColumnBitmapUnionPattern();
         Assert.assertTrue(pattern.match(expr));
     }
 
     @Test
-    public void testUpperCaseOfFunction() {
+    public void testUpperCaseOfFunction(@Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef = new SlotRef(tableName, "c1");
         Deencapsulation.setField(slotRef, "type", Type.INT);
@@ -81,12 +84,13 @@ public class MVColumnBitmapUnionPatternTest {
         List<Expr> params = Lists.newArrayList();
         params.add(child0);
         FunctionCallExpr expr = new FunctionCallExpr(FunctionSet.BITMAP_UNION.toUpperCase(), params);
+        Deencapsulation.setField(expr, "fn", aggregateFunction);
         MVColumnBitmapUnionPattern pattern = new MVColumnBitmapUnionPattern();
         Assert.assertTrue(pattern.match(expr));
     }
 
     @Test
-    public void testIncorrectArithmeticExpr1() {
+    public void testIncorrectArithmeticExpr1(@Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef1 = new SlotRef(tableName, "c1");
         SlotRef slotRef2 = new SlotRef(tableName, "c2");
@@ -94,12 +98,13 @@ public class MVColumnBitmapUnionPatternTest {
         List<Expr> params = Lists.newArrayList();
         params.add(arithmeticExpr);
         FunctionCallExpr expr = new FunctionCallExpr(FunctionSet.BITMAP_UNION, params);
+        Deencapsulation.setField(expr, "fn", aggregateFunction);
         MVColumnBitmapUnionPattern pattern = new MVColumnBitmapUnionPattern();
         Assert.assertFalse(pattern.match(expr));
     }
 
     @Test
-    public void testIncorrectArithmeticExpr2() {
+    public void testIncorrectArithmeticExpr2(@Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef1 = new SlotRef(tableName, "c1");
         SlotRef slotRef2 = new SlotRef(tableName, "c2");
@@ -110,12 +115,13 @@ public class MVColumnBitmapUnionPatternTest {
         List<Expr> params = Lists.newArrayList();
         params.add(child0);
         FunctionCallExpr expr = new FunctionCallExpr(FunctionSet.BITMAP_UNION, params);
+        Deencapsulation.setField(expr, "fn", aggregateFunction);
         MVColumnBitmapUnionPattern pattern = new MVColumnBitmapUnionPattern();
         Assert.assertFalse(pattern.match(expr));
     }
 
     @Test
-    public void testIncorrectDecimalSlotRef() {
+    public void testIncorrectDecimalSlotRef(@Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef1 = new SlotRef(tableName, "c1");
         Deencapsulation.setField(slotRef1, "type", Type.DECIMALV2);
@@ -125,18 +131,20 @@ public class MVColumnBitmapUnionPatternTest {
         List<Expr> params = Lists.newArrayList();
         params.add(child0);
         FunctionCallExpr expr = new FunctionCallExpr(FunctionSet.BITMAP_UNION, params);
+        Deencapsulation.setField(expr, "fn", aggregateFunction);
         MVColumnBitmapUnionPattern pattern = new MVColumnBitmapUnionPattern();
         Assert.assertFalse(pattern.match(expr));
     }
 
     @Test
     public void testAggTableBitmapColumn(@Injectable SlotDescriptor desc,
-            @Injectable Column column) {
+            @Injectable Column column, @Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef1 = new SlotRef(tableName, "c1");
         List<Expr> params = Lists.newArrayList();
         params.add(slotRef1);
         FunctionCallExpr expr = new FunctionCallExpr(FunctionSet.BITMAP_UNION, params);
+        Deencapsulation.setField(expr, "fn", aggregateFunction);
         slotRef1.setType(Type.BITMAP);
         slotRef1.setDesc(desc);
         new Expectations() {
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/MVColumnHLLUnionPatternTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/MVColumnHLLUnionPatternTest.java
index 189365c..5f364f4 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/MVColumnHLLUnionPatternTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/MVColumnHLLUnionPatternTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.doris.analysis;
 
+import org.apache.doris.catalog.AggregateFunction;
 import org.apache.doris.catalog.Column;
 import org.apache.doris.catalog.FunctionSet;
 import org.apache.doris.catalog.Type;
@@ -35,7 +36,7 @@ import mockit.Injectable;
 public class MVColumnHLLUnionPatternTest {
 
     @Test
-    public void testCorrectExpr1() {
+    public void testCorrectExpr1(@Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef = new SlotRef(tableName, "c1");
         List<Expr> child0Params = Lists.newArrayList();
@@ -44,12 +45,13 @@ public class MVColumnHLLUnionPatternTest {
         List<Expr> params = Lists.newArrayList();
         params.add(child0);
         FunctionCallExpr expr = new FunctionCallExpr(FunctionSet.HLL_UNION, params);
+        Deencapsulation.setField(expr, "fn", aggregateFunction);
         MVColumnHLLUnionPattern pattern = new MVColumnHLLUnionPattern();
         Assert.assertTrue(pattern.match(expr));
     }
 
     @Test
-    public void testCorrectExpr2(@Injectable CastExpr castExpr) {
+    public void testCorrectExpr2(@Injectable CastExpr castExpr, @Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef = new SlotRef(tableName, "c1");
         new Expectations() {
@@ -64,12 +66,13 @@ public class MVColumnHLLUnionPatternTest {
         List<Expr> params = Lists.newArrayList();
         params.add(child0);
         FunctionCallExpr expr = new FunctionCallExpr(FunctionSet.HLL_UNION, params);
+        Deencapsulation.setField(expr, "fn", aggregateFunction);
         MVColumnHLLUnionPattern pattern = new MVColumnHLLUnionPattern();
         Assert.assertTrue(pattern.match(expr));
     }
 
     @Test
-    public void testUpperCaseOfFunction() {
+    public void testUpperCaseOfFunction(@Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef = new SlotRef(tableName, "c1");
         List<Expr> child0Params = Lists.newArrayList();
@@ -78,22 +81,24 @@ public class MVColumnHLLUnionPatternTest {
         List<Expr> params = Lists.newArrayList();
         params.add(child0);
         FunctionCallExpr expr = new FunctionCallExpr(FunctionSet.HLL_UNION.toUpperCase(), params);
+        Deencapsulation.setField(expr, "fn", aggregateFunction);
         MVColumnHLLUnionPattern pattern = new MVColumnHLLUnionPattern();
         Assert.assertTrue(pattern.match(expr));
     }
 
     @Test
-    public void testIncorrectLiteralExpr1() {
+    public void testIncorrectLiteralExpr1(@Injectable AggregateFunction aggregateFunction) {
         IntLiteral intLiteral = new IntLiteral(1);
         List<Expr> params = Lists.newArrayList();
         params.add(intLiteral);
         FunctionCallExpr expr = new FunctionCallExpr(FunctionSet.HLL_UNION, params);
+        Deencapsulation.setField(expr, "fn", aggregateFunction);
         MVColumnHLLUnionPattern pattern = new MVColumnHLLUnionPattern();
         Assert.assertFalse(pattern.match(expr));
     }
 
     @Test
-    public void testIncorrectLiteralExpr2() {
+    public void testIncorrectLiteralExpr2(@Injectable AggregateFunction aggregateFunction) {
         IntLiteral intLiteral = new IntLiteral(1);
         List<Expr> child0Params = Lists.newArrayList();
         child0Params.add(intLiteral);
@@ -101,12 +106,13 @@ public class MVColumnHLLUnionPatternTest {
         List<Expr> params = Lists.newArrayList();
         params.add(child0);
         FunctionCallExpr expr = new FunctionCallExpr(FunctionSet.HLL_UNION, params);
+        Deencapsulation.setField(expr, "fn", aggregateFunction);
         MVColumnHLLUnionPattern pattern = new MVColumnHLLUnionPattern();
         Assert.assertFalse(pattern.match(expr));
     }
 
     @Test
-    public void testIncorrectDecimalSlotRef() {
+    public void testIncorrectDecimalSlotRef(@Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef = new SlotRef(tableName, "c1");
         Deencapsulation.setField(slotRef, "type", Type.DECIMALV2);
@@ -116,18 +122,20 @@ public class MVColumnHLLUnionPatternTest {
         List<Expr> params = Lists.newArrayList();
         params.add(child0);
         FunctionCallExpr expr = new FunctionCallExpr(FunctionSet.HLL_UNION, params);
+        Deencapsulation.setField(expr, "fn", aggregateFunction);
         MVColumnHLLUnionPattern pattern = new MVColumnHLLUnionPattern();
         Assert.assertFalse(pattern.match(expr));
     }
 
     @Test
     public void testAggTableHLLColumn(@Injectable SlotDescriptor desc,
-            @Injectable Column column) {
+            @Injectable Column column, @Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef1 = new SlotRef(tableName, "c1");
         List<Expr> params = Lists.newArrayList();
         params.add(slotRef1);
         FunctionCallExpr expr = new FunctionCallExpr(FunctionSet.HLL_UNION, params);
+        Deencapsulation.setField(expr, "fn", aggregateFunction);
         slotRef1.setType(Type.HLL);
         slotRef1.setDesc(desc);
         new Expectations() {
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/MVColumnOneChildPatternTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/MVColumnOneChildPatternTest.java
index dfd47e8..f4c6049 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/MVColumnOneChildPatternTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/MVColumnOneChildPatternTest.java
@@ -17,8 +17,10 @@
 
 package org.apache.doris.analysis;
 
+import org.apache.doris.catalog.AggregateFunction;
 import org.apache.doris.catalog.AggregateType;
 import org.apache.doris.catalog.FunctionSet;
+import org.apache.doris.common.jmockit.Deencapsulation;
 
 import com.google.common.collect.Lists;
 
@@ -33,19 +35,20 @@ import mockit.Injectable;
 public class MVColumnOneChildPatternTest {
 
     @Test
-    public void testCorrectSum() {
+    public void testCorrectSum(@Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef = new SlotRef(tableName, "c1");
         List<Expr> params = Lists.newArrayList();
         params.add(slotRef);
         FunctionCallExpr functionCallExpr = new FunctionCallExpr(AggregateType.SUM.name(), params);
+        Deencapsulation.setField(functionCallExpr, "fn", aggregateFunction);
         MVColumnOneChildPattern mvColumnOneChildPattern = new MVColumnOneChildPattern(
                 AggregateType.SUM.name().toLowerCase());
         Assert.assertTrue(mvColumnOneChildPattern.match(functionCallExpr));
     }
 
     @Test
-    public void testCorrectMin(@Injectable CastExpr castExpr) {
+    public void testCorrectMin(@Injectable CastExpr castExpr, @Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef = new SlotRef(tableName, "c1");
         List<Expr> child0Params = Lists.newArrayList();
@@ -59,35 +62,38 @@ public class MVColumnOneChildPatternTest {
         List<Expr> params = Lists.newArrayList();
         params.add(castExpr);
         FunctionCallExpr functionCallExpr = new FunctionCallExpr(AggregateType.MIN.name(), params);
+        Deencapsulation.setField(functionCallExpr, "fn", aggregateFunction);
         MVColumnOneChildPattern mvColumnOneChildPattern = new MVColumnOneChildPattern(
                 AggregateType.MIN.name().toLowerCase());
         Assert.assertTrue(mvColumnOneChildPattern.match(functionCallExpr));
     }
 
     @Test
-    public void testCorrectCountField() {
+    public void testCorrectCountField(@Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef = new SlotRef(tableName, "c1");
         List<Expr> params = Lists.newArrayList();
         params.add(slotRef);
         FunctionCallExpr functionCallExpr = new FunctionCallExpr(FunctionSet.COUNT, params);
+        Deencapsulation.setField(functionCallExpr, "fn", aggregateFunction);
         MVColumnOneChildPattern mvColumnOneChildPattern = new MVColumnOneChildPattern(FunctionSet.COUNT.toLowerCase());
         Assert.assertTrue(mvColumnOneChildPattern.match(functionCallExpr));
     }
 
     @Test
-    public void testIncorrectLiteral() {
+    public void testIncorrectLiteral(@Injectable AggregateFunction aggregateFunction) {
         IntLiteral intLiteral = new IntLiteral(1);
         List<Expr> params = Lists.newArrayList();
         params.add(intLiteral);
         FunctionCallExpr functionCallExpr = new FunctionCallExpr(AggregateType.SUM.name(), params);
+        Deencapsulation.setField(functionCallExpr, "fn", aggregateFunction);
         MVColumnOneChildPattern mvColumnOneChildPattern = new MVColumnOneChildPattern(
                 AggregateType.SUM.name().toLowerCase());
         Assert.assertFalse(mvColumnOneChildPattern.match(functionCallExpr));
     }
 
     @Test
-    public void testIncorrectArithmeticExpr() {
+    public void testIncorrectArithmeticExpr(@Injectable AggregateFunction aggregateFunction) {
         TableName tableName = new TableName("db", "table");
         SlotRef slotRef1 = new SlotRef(tableName, "c1");
         SlotRef slotRef2 = new SlotRef(tableName, "c2");
@@ -95,6 +101,7 @@ public class MVColumnOneChildPatternTest {
         List<Expr> params = Lists.newArrayList();
         params.add(arithmeticExpr);
         FunctionCallExpr functionCallExpr = new FunctionCallExpr(AggregateType.SUM.name(), params);
+        Deencapsulation.setField(functionCallExpr, "fn", aggregateFunction);
         MVColumnOneChildPattern mvColumnOneChildPattern = new MVColumnOneChildPattern(
                 AggregateType.SUM.name().toLowerCase());
         Assert.assertFalse(mvColumnOneChildPattern.match(functionCallExpr));

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org