EmmyMiao87 commented on a change in pull request #3651: URL: https://github.com/apache/incubator-doris/pull/3651#discussion_r429018055
########## File path: fe/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java ########## @@ -457,8 +462,23 @@ private RollupJobV2 createMaterializedViewJob(String mvName, String baseIndexNam + "duplicate table"); } Column newMVColumn = new Column(baseColumn); + newMVColumn.setIsKey(mvColumnItem.isKey()); newMVColumn.setAggregationType(mvAggregationType, mvColumnItem.isAggregationTypeImplicit()); + newMVColumn.setDefineExpr(mvColumnItem.getDefineExpr()); + if (mvColumnItem.getDefineExpr() != null) { + if (mvAggregationType.equals(BITMAP_UNION)) { + newMVColumn.setType(Type.BITMAP); + newMVColumn.setName(MATERIALIZED_VIEW_NAME_PRFIX + "bitmap_" + baseColumn.getName()); + } else if (mvAggregationType.equals(HLL_UNION)){ + newMVColumn.setType(Type.HLL); + newMVColumn.setName(MATERIALIZED_VIEW_NAME_PRFIX + "hll_" + baseColumn.getName()); + } else { + throw new DdlException("The define expr of column is only support bitmap_union or hll_union"); + } + newMVColumn.setIsKey(false); Review comment: The `isKey` has been set. ########## File path: fe/src/main/java/org/apache/doris/catalog/Column.java ########## @@ -416,6 +483,7 @@ public void write(DataOutput out) throws IOException { stats.write(out); Text.writeString(out, comment); + Text.writeString(out, defineExprString); Review comment: The table object also use the writable interface The fullSchema of table also needs to serialized without GSON, ########## File path: fe/src/main/java/org/apache/doris/alter/MaterializedViewHandler.java ########## @@ -457,8 +462,23 @@ private RollupJobV2 createMaterializedViewJob(String mvName, String baseIndexNam + "duplicate table"); } Column newMVColumn = new Column(baseColumn); + newMVColumn.setIsKey(mvColumnItem.isKey()); newMVColumn.setAggregationType(mvAggregationType, mvColumnItem.isAggregationTypeImplicit()); + newMVColumn.setDefineExpr(mvColumnItem.getDefineExpr()); Review comment: Firstly, check the define expr is forbidden or not. Secondly, set define expr in column ########## File path: fe/src/main/java/org/apache/doris/catalog/Column.java ########## @@ -66,6 +78,10 @@ private String comment; @SerializedName(value = "stats") private ColumnStats stats; // cardinality and selectivity etc. + @SerializedName(value = "defineExprString") + private String defineExprString = ""; + Review comment: Remove this empty line. ########## File path: fe/src/main/java/org/apache/doris/catalog/Column.java ########## @@ -310,6 +333,50 @@ public static String removeNamePrefix(String colName) { return colName; } + public Expr getDefineExpr() { + return defineExpr; + } + + public void setDefineExpr(Expr expr) { + defineExpr = expr; + if (expr != null) { + serializeDefineExpr(expr); + } + } + + public void serializeDefineExpr(Expr defineExpr) { + defineExprString = "COLUMNS (" + name + "=" + defineExpr.toSql() + ")"; Review comment: You need to restore the original statement rather then use the toSql function ########## File path: fe/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java ########## @@ -167,15 +167,25 @@ private void analyzeSelectClause() throws AnalysisException { } else if (selectListItem.getExpr() instanceof FunctionCallExpr) { FunctionCallExpr functionCallExpr = (FunctionCallExpr) selectListItem.getExpr(); String functionName = functionCallExpr.getFnName().getFunction(); + Expr defineExpr = null; // TODO(ml): support REPLACE, REPLACE_IF_NOT_NULL only for aggregate table, HLL_UNION, BITMAP_UNION if (!functionName.equalsIgnoreCase("sum") && !functionName.equalsIgnoreCase("min") - && !functionName.equalsIgnoreCase("max")) { + && !functionName.equalsIgnoreCase("max") + && !functionName.equalsIgnoreCase("bitmap_union") Review comment: The bitmap_union and hll_union should still be banned. ########## File path: fe/src/main/java/org/apache/doris/common/FeMetaVersion.java ########## @@ -179,6 +179,8 @@ public static final int VERSION_83 = 83; // add storage format in schema change job public static final int VERSION_84 = 84; + // support define expr in materialized view Review comment: The bitmap_union mv should be forbidden now. So the meta version could not be changed. ########## File path: fe/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java ########## @@ -187,6 +197,14 @@ else if (functionChild0 instanceof CastExpr throw new AnalysisException("The children of aggregate function only support one original column. " + "Error function: " + functionCallExpr.toSqlImpl()); } + + if (functionName.equalsIgnoreCase("bitmap_union")) { + if (!slotRef.type.isIntegerType()) { Review comment: The child type of bitmap_union must be bitmap rather then integer. Also the child type of to_bitmap function has been checked in analyzer. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org