adonis0147 commented on code in PR #20355:
URL: https://github.com/apache/doris/pull/20355#discussion_r1213872279


##########
fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMultiTableMaterializedViewStmt.java:
##########
@@ -117,11 +119,40 @@ private void analyzeSelectClause(SelectStmt selectStmt) 
throws AnalysisException
             tables.put(table.getName(), table);
             tables.put(tableRef.getAlias(), table);
         }
-        columnDefs = generateColumnDefinitions(selectStmt.getSelectList());
+        for (SelectListItem item : selectStmt.getSelectList().getItems()) {
+            if (item.isStar()) {
+                continue;
+            }
+            Expr itemExpr = item.getExpr();
+            String alias = item.getAlias();
+            if (itemExpr instanceof SlotRef) {
+                continue;
+            } else if (itemExpr instanceof FunctionCallExpr && 
((FunctionCallExpr) itemExpr).isAggregateFunction()) {
+                FunctionCallExpr functionCallExpr = (FunctionCallExpr) 
itemExpr;
+                String functionName = 
functionCallExpr.getFnName().getFunction();
+                MVColumnPattern mvColumnPattern = 
CreateMaterializedViewStmt.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);
+                }
+                if (StringUtils.isEmpty(alias)) {
+                    throw new AnalysisException("Function expr: " + 
functionName + " must have a alias name for MTMV.");
+                }
+            } else {
+                throw new AnalysisException(
+                        "Materialized view does not support this expr:" + 
itemExpr.toSqlImpl());

Review Comment:
   The function `analyzeSelectClause` is too large. Please try to use some 
small functions to organize the implementation.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to