EmmyMiao87 commented on a change in pull request #8348:
URL: https://github.com/apache/incubator-doris/pull/8348#discussion_r837389102



##########
File path: 
fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsJobManager.java
##########
@@ -18,56 +18,128 @@
 package org.apache.doris.statistics;
 
 import org.apache.doris.analysis.AnalyzeStmt;
+import org.apache.doris.analysis.UserIdentity;
 import org.apache.doris.catalog.Catalog;
+import org.apache.doris.catalog.Database;
+import org.apache.doris.catalog.Table;
+import org.apache.doris.common.Config;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.mysql.privilege.PaloAuth;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+import org.apache.doris.statistics.StatisticsJob.JobState;
 
 import com.google.common.collect.Maps;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
+import java.util.List;
 import java.util.Map;
+import java.util.Queue;
 import java.util.Set;
 
-/*
-For unified management of statistics job,
-including job addition, cancellation, scheduling, etc.
+/**
+ * For unified management of statistics job,
+ * including job addition, cancellation, scheduling, etc.
  */
 public class StatisticsJobManager {
     private static final Logger LOG = 
LogManager.getLogger(StatisticsJobManager.class);
 
-    // statistics job
-    private Map<Long, StatisticsJob> idToStatisticsJob = 
Maps.newConcurrentMap();
+    /**
+     * save statistics job status information
+     */
+    private final Map<Long, StatisticsJob> idToStatisticsJob = 
Maps.newConcurrentMap();
 
-    public void createStatisticsJob(AnalyzeStmt analyzeStmt) {
+    public Map<Long, StatisticsJob> getIdToStatisticsJob() {
+        return idToStatisticsJob;
+    }
+
+    public void createStatisticsJob(AnalyzeStmt analyzeStmt) throws 
DdlException {

Review comment:
       It should be called by DdlExecutor.

##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyzeStmt.java
##########
@@ -31,5 +34,30 @@
  *
  */
 public class AnalyzeStmt extends DdlStmt {
+    private final TableName tbl;
+    private final List<String> columnNames;
+    private final Map<String, String> properties;
+
+    public AnalyzeStmt(TableName tbl, List<String> columns, Map<String, 
String> properties) {
+        this.tbl = tbl;
+        this.columnNames = columns;
+        this.properties = properties;
+    }
+

Review comment:
       Missing analyze function.
   analyze() {
       1. analyze TableName
       2. analyze column name
       3. analyze properties
   }

##########
File path: 
fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsJobManager.java
##########
@@ -18,56 +18,128 @@
 package org.apache.doris.statistics;
 
 import org.apache.doris.analysis.AnalyzeStmt;
+import org.apache.doris.analysis.UserIdentity;
 import org.apache.doris.catalog.Catalog;
+import org.apache.doris.catalog.Database;
+import org.apache.doris.catalog.Table;
+import org.apache.doris.common.Config;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.mysql.privilege.PaloAuth;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+import org.apache.doris.statistics.StatisticsJob.JobState;
 
 import com.google.common.collect.Maps;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
+import java.util.List;
 import java.util.Map;
+import java.util.Queue;
 import java.util.Set;
 
-/*
-For unified management of statistics job,
-including job addition, cancellation, scheduling, etc.
+/**
+ * For unified management of statistics job,
+ * including job addition, cancellation, scheduling, etc.
  */
 public class StatisticsJobManager {
     private static final Logger LOG = 
LogManager.getLogger(StatisticsJobManager.class);
 
-    // statistics job
-    private Map<Long, StatisticsJob> idToStatisticsJob = 
Maps.newConcurrentMap();
+    /**
+     * save statistics job status information
+     */
+    private final Map<Long, StatisticsJob> idToStatisticsJob = 
Maps.newConcurrentMap();
 
-    public void createStatisticsJob(AnalyzeStmt analyzeStmt) {
+    public Map<Long, StatisticsJob> getIdToStatisticsJob() {
+        return idToStatisticsJob;
+    }
+
+    public void createStatisticsJob(AnalyzeStmt analyzeStmt) throws 
DdlException {
         // step0: init statistics job by analyzeStmt
         StatisticsJob statisticsJob = 
StatisticsJob.fromAnalyzeStmt(analyzeStmt);
-        // step1: get statistics to be analyzed
-        Set<Long> tableIdList = statisticsJob.relatedTableId();
+
+        // step1: get statistical db&tbl to be analyzed
+        long dbId = statisticsJob.getDbId();
+        Set<Long> tableIds = statisticsJob.relatedTableId();
+
         // step2: check restrict
-        checkRestrict(tableIdList);
+        this.checkRestrict(dbId, tableIds);
+
         // step3: check permission
-        checkPermission();
+        UserIdentity userInfo = analyzeStmt.getUserInfo();
+        this.checkPermission(dbId, tableIds, userInfo);

Review comment:
       same as above

##########
File path: 
fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsJobManager.java
##########
@@ -18,56 +18,128 @@
 package org.apache.doris.statistics;
 
 import org.apache.doris.analysis.AnalyzeStmt;
+import org.apache.doris.analysis.UserIdentity;
 import org.apache.doris.catalog.Catalog;
+import org.apache.doris.catalog.Database;
+import org.apache.doris.catalog.Table;
+import org.apache.doris.common.Config;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.mysql.privilege.PaloAuth;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+import org.apache.doris.statistics.StatisticsJob.JobState;
 
 import com.google.common.collect.Maps;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
+import java.util.List;
 import java.util.Map;
+import java.util.Queue;
 import java.util.Set;
 
-/*
-For unified management of statistics job,
-including job addition, cancellation, scheduling, etc.
+/**
+ * For unified management of statistics job,
+ * including job addition, cancellation, scheduling, etc.
  */
 public class StatisticsJobManager {
     private static final Logger LOG = 
LogManager.getLogger(StatisticsJobManager.class);
 
-    // statistics job
-    private Map<Long, StatisticsJob> idToStatisticsJob = 
Maps.newConcurrentMap();
+    /**
+     * save statistics job status information
+     */
+    private final Map<Long, StatisticsJob> idToStatisticsJob = 
Maps.newConcurrentMap();
 
-    public void createStatisticsJob(AnalyzeStmt analyzeStmt) {
+    public Map<Long, StatisticsJob> getIdToStatisticsJob() {
+        return idToStatisticsJob;
+    }
+
+    public void createStatisticsJob(AnalyzeStmt analyzeStmt) throws 
DdlException {
         // step0: init statistics job by analyzeStmt
         StatisticsJob statisticsJob = 
StatisticsJob.fromAnalyzeStmt(analyzeStmt);
-        // step1: get statistics to be analyzed
-        Set<Long> tableIdList = statisticsJob.relatedTableId();
+
+        // step1: get statistical db&tbl to be analyzed
+        long dbId = statisticsJob.getDbId();
+        Set<Long> tableIds = statisticsJob.relatedTableId();
+
         // step2: check restrict
-        checkRestrict(tableIdList);
+        this.checkRestrict(dbId, tableIds);

Review comment:
       Is it the same to use this or not to use this here?

##########
File path: 
fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsJobManager.java
##########
@@ -18,56 +18,128 @@
 package org.apache.doris.statistics;
 
 import org.apache.doris.analysis.AnalyzeStmt;
+import org.apache.doris.analysis.UserIdentity;
 import org.apache.doris.catalog.Catalog;
+import org.apache.doris.catalog.Database;
+import org.apache.doris.catalog.Table;
+import org.apache.doris.common.Config;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.mysql.privilege.PaloAuth;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+import org.apache.doris.statistics.StatisticsJob.JobState;
 
 import com.google.common.collect.Maps;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
+import java.util.List;
 import java.util.Map;
+import java.util.Queue;
 import java.util.Set;
 
-/*
-For unified management of statistics job,
-including job addition, cancellation, scheduling, etc.
+/**
+ * For unified management of statistics job,
+ * including job addition, cancellation, scheduling, etc.
  */
 public class StatisticsJobManager {
     private static final Logger LOG = 
LogManager.getLogger(StatisticsJobManager.class);
 
-    // statistics job
-    private Map<Long, StatisticsJob> idToStatisticsJob = 
Maps.newConcurrentMap();
+    /**
+     * save statistics job status information
+     */
+    private final Map<Long, StatisticsJob> idToStatisticsJob = 
Maps.newConcurrentMap();
 
-    public void createStatisticsJob(AnalyzeStmt analyzeStmt) {
+    public Map<Long, StatisticsJob> getIdToStatisticsJob() {
+        return idToStatisticsJob;
+    }
+
+    public void createStatisticsJob(AnalyzeStmt analyzeStmt) throws 
DdlException {
         // step0: init statistics job by analyzeStmt
         StatisticsJob statisticsJob = 
StatisticsJob.fromAnalyzeStmt(analyzeStmt);
-        // step1: get statistics to be analyzed
-        Set<Long> tableIdList = statisticsJob.relatedTableId();
+
+        // step1: get statistical db&tbl to be analyzed
+        long dbId = statisticsJob.getDbId();
+        Set<Long> tableIds = statisticsJob.relatedTableId();
+
         // step2: check restrict
-        checkRestrict(tableIdList);
+        this.checkRestrict(dbId, tableIds);
+
         // step3: check permission
-        checkPermission();
+        UserIdentity userInfo = analyzeStmt.getUserInfo();
+        this.checkPermission(dbId, tableIds, userInfo);
+
         // step4: create it
-        createStatisticsJob(statisticsJob);
+        this.createStatisticsJob(statisticsJob);

Review comment:
       same as above




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