fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsJobManager.java
private void checkRestrict(long dbId, Set<Long> tableIds) throws DdlException {
        Database db = Catalog.getCurrentCatalog().getDbOrDdlException(dbId);

        // check table type
        for (Long tableId : tableIds) {
            Table table = db.getTableOrDdlException(tableId);
            if (table.getType() != Table.TableType.OLAP) {
                throw new DdlException("The external table(" + table.getName() + ") is not supported.");
            }
        }

        int unfinishedJobs = 0;
        StatisticsJobScheduler jobScheduler = Catalog.getCurrentCatalog().getStatisticsJobScheduler();
        Queue<StatisticsJob> statisticsJobs = jobScheduler.pendingJobQueue;

        // check table unfinished job
        for (StatisticsJob statisticsJob : statisticsJobs) {
            JobState jobState = statisticsJob.getJobState();
            List<Long> tableIdList = statisticsJob.getTableIds();
            if (jobState == JobState.PENDING || jobState == JobState.SCHEDULING || jobState == JobState.RUNNING) {
                for (Long tableId : tableIds) {
                    if (tableIdList.contains(tableId)) {
                        throw new DdlException("The same table(id=" + tableId + ") cannot have two unfinished statistics jobs.");
                    }
                }
                unfinishedJobs++;
            }
        }

        // check the number of unfinished tasks
        if (unfinishedJobs > Config.cbo_max_statistics_job_num) {
            throw new DdlException("The unfinished statistics job could not more then Config.cbo_max_statistics_job_num.");
        }
    }
/**
     * Rule1: The same table cannot have two unfinished statistics jobs
     * Rule2: The unfinished statistics job could not more then Config.max_statistics_job_num
     * Rule3: The job for external table is not supported
     */
The same table cannot have two unfinished statistics jobs
Rule2: The unfinished statistics job could not more then Config.max_statistics_job_num
Rule3: The job for external table is not supported
The same table cannot have two unfinished statistics jobs Rule2 : The unfinished statistics job could not more then Config . max_statistics_job_num Rule3 : The job for external table is not supported
private void checkRestrict(long dbId, Set<Long> tableIds) throws DdlException {
        Database db = Catalog.getCurrentCatalog().getDbOrDdlException(dbId);
        for (Long tableId : tableIds) {
            Table table = db.getTableOrDdlException(tableId);
            if (table.getType() != Table.TableType.OLAP) {
                throw new DdlException("The external table(" + table.getName() + ") is not supported.");
            }
        }
        int unfinishedJobs = 0;
        StatisticsJobScheduler jobScheduler = Catalog.getCurrentCatalog().getStatisticsJobScheduler();
        Queue<StatisticsJob> statisticsJobs = jobScheduler.pendingJobQueue;
        for (StatisticsJob statisticsJob : statisticsJobs) {
            JobState jobState = statisticsJob.getJobState();
            List<Long> tableIdList = statisticsJob.getTableIds();
            if (jobState == JobState.PENDING || jobState == JobState.SCHEDULING || jobState == JobState.RUNNING) {
                for (Long tableId : tableIds) {
                    if (tableIdList.contains(tableId)) {
                        throw new DdlException("The same table(id=" + tableId + ") cannot have two unfinished statistics jobs.");
                    }
                }
                unfinishedJobs++;
            }
        }
        if (unfinishedJobs > Config.cbo_max_statistics_job_num) {
            throw new DdlException("The unfinished statistics job could not more then Config.cbo_max_statistics_job_num.");
        }
    }
private void checkRestrict ( long dbId , Set < Long > tableIds ) throws DdlException { Database db = Catalog . getCurrentCatalog ( ) . getDbOrDdlException ( dbId ) ; for ( Long tableId : tableIds ) { Table table = db . getTableOrDdlException ( tableId ) ; if ( table . getType ( ) != Table . TableType . OLAP ) { throw new DdlException ( "The external table(" + table . getName ( ) + ") is not supported." ) ; } } int unfinishedJobs = 0 ; StatisticsJobScheduler jobScheduler = Catalog . getCurrentCatalog ( ) . getStatisticsJobScheduler ( ) ; Queue < StatisticsJob > statisticsJobs = jobScheduler . pendingJobQueue ; for ( StatisticsJob statisticsJob : statisticsJobs ) { JobState jobState = statisticsJob . getJobState ( ) ; List < Long > tableIdList = statisticsJob . getTableIds ( ) ; if ( jobState == JobState . PENDING || jobState == JobState . SCHEDULING || jobState == JobState . RUNNING ) { for ( Long tableId : tableIds ) { if ( tableIdList . contains ( tableId ) ) { throw new DdlException ( "The same table(id=" + tableId + ") cannot have two unfinished statistics jobs." ) ; } } unfinishedJobs ++ ; } } if ( unfinishedJobs > Config . cbo_max_statistics_job_num ) { throw new DdlException ( "The unfinished statistics job could not more then Config.cbo_max_statistics_job_num." ) ; } }
Rule1: The same table cannot have two unfinished statistics jobs
 Rule2: The unfinished statistics job could not more then Config.max_statistics_job_num
 Rule3: The job for external table is not supported
Rule1 : The same table cannot have two unfinished statistics jobs Rule2 : The unfinished statistics job could not more then Config . max_statistics_job_num Rule3 : The job for external table is not supported
// check table type // check table unfinished job // check the number of unfinished tasks