Code review comment: The function `analyzeSelectClause` is too large. Please try to use some small functions to organize the implementation.

Code under review:
private void analyzeSelectClause(SelectStmt selectStmt) throws AnalysisException {
        for (TableRef tableRef : selectStmt.getTableRefs()) {
            TableIf table = null;
            if (tableRef instanceof BaseTableRef) {
                String dbName = tableRef.getName().getDb();
                String ctlName = tableRef.getName().getCtl();
                CatalogIf catalogIf = Env.getCurrentEnv().getCatalogMgr().getCatalog(ctlName);
                if (catalogIf == null) {
                    throw new AnalysisException("Failed to get the catalog: " + ctlName);
                }
                Optional<DatabaseIf> dbIf = catalogIf.getDb(dbName);
                if (!dbIf.isPresent()) {
                    throw new AnalysisException("Failed to get the database: " + dbName);
                }
                Optional<TableIf> tableIf = dbIf.get().getTable(tableRef.getName().getTbl());
                if (!tableIf.isPresent()) {
                    throw new AnalysisException("Failed to get the table: " + tableRef.getName().getTbl());
                }
                table = tableIf.orElse(null);
            } else if (tableRef instanceof InlineViewRef) {
                InlineViewRef inlineViewRef = (InlineViewRef) tableRef;
                table = inlineViewRef.getDesc().getTable();
            }
            if (table == null) {
                throw new AnalysisException("Failed to get the table by " + tableRef);
            }
            tables.put(table.getName(), table);
            tables.put(tableRef.getAlias(), table);
        }
        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());
            }
        }
        columnDefs = generateColumnDefinitions(selectStmt);
    }

Line commented on: "Materialized view does not support this expr:" + itemExpr.toSqlImpl());

Revised code:
private void analyzeSelectClause(SelectStmt selectStmt) throws AnalysisException {
        for (TableRef tableRef : selectStmt.getTableRefs()) {
            TableIf table = null;
            if (tableRef instanceof BaseTableRef) {
                String dbName = tableRef.getName().getDb();
                String ctlName = tableRef.getName().getCtl();
                CatalogIf catalogIf = Env.getCurrentEnv().getCatalogMgr().getCatalog(ctlName);
                if (catalogIf == null) {
                    throw new AnalysisException("Failed to get the catalog: " + ctlName);
                }
                Optional<DatabaseIf> dbIf = catalogIf.getDb(dbName);
                if (!dbIf.isPresent()) {
                    throw new AnalysisException("Failed to get the database: " + dbName);
                }
                Optional<TableIf> tableIf = dbIf.get().getTable(tableRef.getName().getTbl());
                if (!tableIf.isPresent()) {
                    throw new AnalysisException("Failed to get the table: " + tableRef.getName().getTbl());
                }
                table = tableIf.orElse(null);
            } else if (tableRef instanceof InlineViewRef) {
                InlineViewRef inlineViewRef = (InlineViewRef) tableRef;
                table = inlineViewRef.getDesc().getTable();
            }
            if (table == null) {
                throw new AnalysisException("Failed to get the table by " + tableRef);
            }
            tables.put(table.getName(), table);
            tables.put(tableRef.getAlias(), table);
        }
        checkSelectListItems(selectStmt.getSelectList().getItems());
        columnDefs = generateColumnDefinitions(selectStmt);
    }