Code review comment: Please  1. Check the valid of metadata 2. Check the permission  The logic of the two should not be interspersed and executed together

Code under review:
public void analyze(Analyzer analyzer) throws UserException {
        super.analyze(analyzer);

        
        if (this.dbTableName != null) {
            String dbName;
            if (Strings.isNullOrEmpty(this.dbTableName.getDb())) {
                dbName = analyzer.getDefaultDb();
            } else {
                dbName = ClusterNamespace.getFullName(analyzer.getClusterName(), this.dbTableName.getDb());
            }

            
            if (Strings.isNullOrEmpty(dbName)) {
                ErrorReport.reportAnalysisException(ErrorCode.ERR_NO_DB_ERROR);
            }
            this.db = analyzer.getCatalog().getDbOrAnalysisException(dbName);

            
            String tblName = this.dbTableName.getTbl();
            if (Strings.isNullOrEmpty(tblName)) {
                this.tables = this.db.getTables();
                for (Table table : this.tables) {
                    checkAnalyzePriv(dbName, table.getName());
                }
            } else {
                Table table = this.db.getTableOrAnalysisException(tblName);
                this.tables = Collections.singletonList(table);
                checkAnalyzePriv(dbName, table.getName());
            }

            
            if (this.columnNames == null || this.columnNames.isEmpty()) {
                setTableIdToColumnName();
            } else {
                Table table = this.db.getTableOrAnalysisException(tblName);
                for (String columnName : this.columnNames) {
                    Column column = table.getColumn(columnName);
                    if (column == null) {
                        ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME, columnName);
                    }
                }
                this.tableIdToColumnName.put(table.getId(), this.columnNames);
            }
        } else {
            
            String dbName = analyzer.getDefaultDb();
            if (Strings.isNullOrEmpty(dbName)) {
                ErrorReport.reportAnalysisException(ErrorCode.ERR_NO_DB_ERROR);
            }
            this.db = analyzer.getCatalog().getDbOrAnalysisException(dbName);
            this.tables = this.db.getTables();
            for (Table table : this.tables) {
                checkAnalyzePriv(dbName, table.getName());
            }
            setTableIdToColumnName();
        }

        
        if (this.properties != null) {
            for (Map.Entry<String, String> pros : this.properties.entrySet()) {
                if (!"cbo_statistics_task_timeout_sec".equals(pros.getKey())) {
                    throw new AnalysisException("Unsupported property: " + pros.getKey());
                }
                if (!StringUtils.isNumeric(pros.getValue()) || Integer.parseInt(pros.getValue()) <= 0) {
                    throw new AnalysisException("Invalid property value: " + pros.getValue());
                }
            }
        } else {
            this.properties = Maps.newHashMap();
            this.properties.put("cbo_statistics_task_timeout_sec", String.valueOf(Config.cbo_statistics_task_timeout_sec));
        }
    }

Line commented on: if (Strings.isNullOrEmpty(dbName)) {

Revised code:
public void analyze(Analyzer analyzer) throws UserException {
        super.analyze(analyzer);

        
        if (this.dbTableName != null) {
            this.dbTableName.analyze(analyzer);
            String dbName = this.dbTableName.getDb();
            String tblName = this.dbTableName.getTbl();
            checkAnalyzePriv(dbName, tblName);

            Database db = analyzer.getCatalog().getDbOrAnalysisException(dbName);
            Table table = db.getTableOrAnalysisException(tblName);

            if (this.columnNames != null && !this.columnNames.isEmpty()) {
                table.readLock();
                try {
                    List<String> baseSchema = table.getBaseSchema(false)
                            .stream().map(Column::getName).collect(Collectors.toList());
                    Optional<String> optional = this.columnNames.stream()
                            .filter(entity -> !baseSchema.contains(entity)).findFirst();
                    if (optional.isPresent()) {
                        String columnName = optional.get();
                        ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_COLUMN_NAME, columnName);
                    }
                } finally {
                    table.readUnlock();
                }
            }

            this.dbId = db.getId();
            this.tblIds.add(table.getId());
        } else {
            
            String dbName = analyzer.getDefaultDb();
            if (Strings.isNullOrEmpty(dbName)) {
                ErrorReport.reportAnalysisException(ErrorCode.ERR_NO_DB_ERROR);
            }
            Database db = analyzer.getCatalog().getDbOrAnalysisException(dbName);

            db.readLock();
            try {
                List<Table> tables = db.getTables();
                for (Table table : tables) {
                    checkAnalyzePriv(dbName, table.getName());
                }

                this.dbId = db.getId();
                for (Table table : tables) {
                    long tblId = table.getId();
                    this.tblIds.add(tblId);
                }
            } finally {
                db.readUnlock();
            }
        }

        
        checkProperties();
    }