This is an automated email from the ASF dual-hosted git repository.

lijibing pushed a commit to branch high-priority-column
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 343f6b38048390d3d44c15677c65027af2aea934
Author: Jibing-Li <64681310+jibing...@users.noreply.github.com>
AuthorDate: Tue Apr 2 12:11:45 2024 +0800

    Fix ut. (#33147)
---
 .../doris/statistics/FollowerColumnSender.java     |   3 +-
 .../doris/statistics/StatisticsAutoCollector.java  |   4 -
 .../doris/statistics/StatisticsJobAppender.java    |   3 +
 .../apache/doris/statistics/TableStatsMeta.java    |   2 +-
 .../apache/doris/statistics/AnalysisJobTest.java   |   4 +-
 .../doris/statistics/AnalysisManagerTest.java      | 280 ++++++-------
 .../doris/statistics/FollowerColumnSenderTest.java |  25 +-
 .../statistics/StatisticsAutoCollectorTest.java    | 178 ++++-----
 .../statistics/StatisticsJobAppenderTest.java      | 441 ++++++++++++---------
 .../doris/statistics/TableStatsMetaTest.java       |  12 +-
 10 files changed, 502 insertions(+), 450 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/statistics/FollowerColumnSender.java
 
b/fe/fe-core/src/main/java/org/apache/doris/statistics/FollowerColumnSender.java
index b5b80741a2b..0e66c7f8a75 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/statistics/FollowerColumnSender.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/statistics/FollowerColumnSender.java
@@ -118,7 +118,8 @@ public class FollowerColumnSender extends MasterDaemon {
     protected Set<TQueryColumn> getNeedAnalyzeColumns(Queue<QueryColumn> 
columnQueue) {
         Set<TQueryColumn> ret = Sets.newHashSet();
         TableIf table;
-        for (int i = 0; i < columnQueue.size(); i++) {
+        int size = columnQueue.size();
+        for (int i = 0; i < size; i++) {
             QueryColumn column = columnQueue.poll();
             if (column == null) {
                 continue;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsAutoCollector.java
 
b/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsAutoCollector.java
index bf0179f5603..0b37ede5a49 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsAutoCollector.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsAutoCollector.java
@@ -234,8 +234,4 @@ public class StatisticsAutoCollector extends MasterDaemon {
             future.get();
         }
     }
-
-    protected AnalysisInfo getNeedAnalyzeColumns(AnalysisInfo jobInfo) {
-        return jobInfo;
-    }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsJobAppender.java
 
b/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsJobAppender.java
index be5b933ce83..74484a06afa 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsJobAppender.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsJobAppender.java
@@ -155,6 +155,9 @@ public class StatisticsJobAppender extends MasterDaemon {
                 if (!(t instanceof OlapTable) || t.getId() <= currentTableId) {
                     continue;
                 }
+                if (t.getBaseSchema().size() > 
StatisticsUtil.getAutoAnalyzeTableWidthThreshold()) {
+                    continue;
+                }
                 Set<Pair<String, String>> columnIndexPairs = 
t.getColumnIndexPairs(
                         t.getSchemaAllIndexes(false).stream()
                                 .filter(c -> 
!StatisticsUtil.isUnsupportedType(c.getType()))
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/statistics/TableStatsMeta.java 
b/fe/fe-core/src/main/java/org/apache/doris/statistics/TableStatsMeta.java
index 90060627646..a5073a92214 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/statistics/TableStatsMeta.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/TableStatsMeta.java
@@ -148,7 +148,7 @@ public class TableStatsMeta implements Writable {
             if (tableIf instanceof OlapTable) {
                 rowCount = analyzedJob.rowCount;
             }
-            if (rowCount == 0 && 
analyzedJob.analysisMethod.equals(AnalysisMethod.SAMPLE)) {
+            if (rowCount == 0 && 
AnalysisMethod.SAMPLE.equals(analyzedJob.analysisMethod)) {
                 return;
             }
             if (analyzedJob.jobColumns.containsAll(
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/statistics/AnalysisJobTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/statistics/AnalysisJobTest.java
index cb2637d5cf6..8a163523eeb 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/statistics/AnalysisJobTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/statistics/AnalysisJobTest.java
@@ -80,7 +80,7 @@ public class AnalysisJobTest {
 
         new MockUp<AnalysisJob>() {
             @Mock
-            protected void writeBuf() {
+            protected void flushBuffer() {
                 writeBufInvokeTimes.incrementAndGet();
             }
 
@@ -111,7 +111,7 @@ public class AnalysisJobTest {
 
         new MockUp<AnalysisJob>() {
             @Mock
-            protected void writeBuf() {
+            protected void flushBuffer() {
                 writeBufInvokeTimes.incrementAndGet();
             }
 
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/statistics/AnalysisManagerTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/statistics/AnalysisManagerTest.java
index 529e0089511..9c6580ee5cc 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/statistics/AnalysisManagerTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/statistics/AnalysisManagerTest.java
@@ -21,6 +21,8 @@ import org.apache.doris.analysis.AnalyzeProperties;
 import org.apache.doris.analysis.AnalyzeTblStmt;
 import org.apache.doris.analysis.PartitionNames;
 import org.apache.doris.analysis.ShowAnalyzeStmt;
+import org.apache.doris.analysis.ShowAutoAnalyzeJobsStmt;
+import org.apache.doris.analysis.StatementBase;
 import org.apache.doris.analysis.TableName;
 import org.apache.doris.catalog.Column;
 import org.apache.doris.catalog.Database;
@@ -497,143 +499,143 @@ public class AnalysisManagerTest {
         Assertions.assertEquals(0, analysisManager.midPriorityColumns.size());
     }
 
-    // @Test
-    // public void testShowAutoJobs() {
-    //     AnalysisManager manager = new AnalysisManager();
-    //     TableName high1 = new TableName("catalog1", "db1", "high1");
-    //     TableName high2 = new TableName("catalog2", "db2", "high2");
-    //     TableName mid1 = new TableName("catalog3", "db3", "mid1");
-    //     TableName mid2 = new TableName("catalog4", "db4", "mid2");
-    //     TableName low1 = new TableName("catalog5", "db5", "low1");
-    //
-    //     manager.highPriorityJobs.put(high1, new HashSet<String>());
-    //     manager.highPriorityJobs.get(high1).add("col1");
-    //     manager.highPriorityJobs.get(high1).add("col2");
-    //     manager.highPriorityJobs.put(high2, new HashSet<String>());
-    //     manager.highPriorityJobs.get(high2).add("col3");
-    //     manager.midPriorityJobs.put(mid1, new HashSet<String>());
-    //     manager.midPriorityJobs.get(mid1).add("col4");
-    //     manager.midPriorityJobs.put(mid2, new HashSet<String>());
-    //     manager.midPriorityJobs.get(mid2).add("col5");
-    //     manager.lowPriorityJobs.put(low1, new HashSet<String>());
-    //     manager.lowPriorityJobs.get(low1).add("col6");
-    //     manager.lowPriorityJobs.get(low1).add("col7");
-    //
-    //     new MockUp<StatementBase>() {
-    //         @Mock
-    //         public boolean isAnalyzed() {
-    //             return true;
-    //         }
-    //     };
-    //     ShowAutoAnalyzeJobsStmt stmt = new ShowAutoAnalyzeJobsStmt(null, 
null);
-    //     List<AutoAnalysisPendingJob> autoAnalysisPendingJobs = 
manager.showAutoPendingJobs(stmt);
-    //     Assertions.assertEquals(5, autoAnalysisPendingJobs.size());
-    //     AutoAnalysisPendingJob job = autoAnalysisPendingJobs.get(0);
-    //     Assertions.assertEquals("catalog1", job.catalogName);
-    //     Assertions.assertEquals("db1", job.dbName);
-    //     Assertions.assertEquals("high1", job.tableName);
-    //     Assertions.assertEquals(2, job.columnNames.size());
-    //     Assertions.assertTrue(job.columnNames.contains("col1"));
-    //     Assertions.assertTrue(job.columnNames.contains("col2"));
-    //     Assertions.assertEquals(JobPriority.HIGH, job.priority);
-    //
-    //     job = autoAnalysisPendingJobs.get(1);
-    //     Assertions.assertEquals("catalog2", job.catalogName);
-    //     Assertions.assertEquals("db2", job.dbName);
-    //     Assertions.assertEquals("high2", job.tableName);
-    //     Assertions.assertEquals(1, job.columnNames.size());
-    //     Assertions.assertTrue(job.columnNames.contains("col3"));
-    //     Assertions.assertEquals(JobPriority.HIGH, job.priority);
-    //
-    //     job = autoAnalysisPendingJobs.get(2);
-    //     Assertions.assertEquals("catalog3", job.catalogName);
-    //     Assertions.assertEquals("db3", job.dbName);
-    //     Assertions.assertEquals("mid1", job.tableName);
-    //     Assertions.assertEquals(1, job.columnNames.size());
-    //     Assertions.assertTrue(job.columnNames.contains("col4"));
-    //     Assertions.assertEquals(JobPriority.MID, job.priority);
-    //
-    //     job = autoAnalysisPendingJobs.get(3);
-    //     Assertions.assertEquals("catalog4", job.catalogName);
-    //     Assertions.assertEquals("db4", job.dbName);
-    //     Assertions.assertEquals("mid2", job.tableName);
-    //     Assertions.assertEquals(1, job.columnNames.size());
-    //     Assertions.assertTrue(job.columnNames.contains("col5"));
-    //     Assertions.assertEquals(JobPriority.MID, job.priority);
-    //
-    //     job = autoAnalysisPendingJobs.get(4);
-    //     Assertions.assertEquals("catalog5", job.catalogName);
-    //     Assertions.assertEquals("db5", job.dbName);
-    //     Assertions.assertEquals("low1", job.tableName);
-    //     Assertions.assertEquals(2, job.columnNames.size());
-    //     Assertions.assertTrue(job.columnNames.contains("col6"));
-    //     Assertions.assertTrue(job.columnNames.contains("col7"));
-    //     Assertions.assertEquals(JobPriority.LOW, job.priority);
-    //
-    //     new MockUp<ShowAutoAnalyzeJobsStmt>() {
-    //         @Mock
-    //         public String getPriority() {
-    //             return JobPriority.HIGH.name().toUpperCase();
-    //         }
-    //     };
-    //     List<AutoAnalysisPendingJob> highJobs = 
manager.showAutoPendingJobs(stmt);
-    //     Assertions.assertEquals(2, highJobs.size());
-    //     job = highJobs.get(0);
-    //     Assertions.assertEquals("catalog1", job.catalogName);
-    //     Assertions.assertEquals("db1", job.dbName);
-    //     Assertions.assertEquals("high1", job.tableName);
-    //     Assertions.assertEquals(2, job.columnNames.size());
-    //     Assertions.assertTrue(job.columnNames.contains("col1"));
-    //     Assertions.assertTrue(job.columnNames.contains("col2"));
-    //     Assertions.assertEquals(JobPriority.HIGH, job.priority);
-    //
-    //     job = highJobs.get(1);
-    //     Assertions.assertEquals("catalog2", job.catalogName);
-    //     Assertions.assertEquals("db2", job.dbName);
-    //     Assertions.assertEquals("high2", job.tableName);
-    //     Assertions.assertEquals(1, job.columnNames.size());
-    //     Assertions.assertTrue(job.columnNames.contains("col3"));
-    //     Assertions.assertEquals(JobPriority.HIGH, job.priority);
-    //
-    //     new MockUp<ShowAutoAnalyzeJobsStmt>() {
-    //         @Mock
-    //         public String getPriority() {
-    //             return JobPriority.MID.name().toUpperCase();
-    //         }
-    //     };
-    //     List<AutoAnalysisPendingJob> midJobs = 
manager.showAutoPendingJobs(stmt);
-    //     Assertions.assertEquals(2, midJobs.size());
-    //     job = midJobs.get(0);
-    //     Assertions.assertEquals("catalog3", job.catalogName);
-    //     Assertions.assertEquals("db3", job.dbName);
-    //     Assertions.assertEquals("mid1", job.tableName);
-    //     Assertions.assertEquals(1, job.columnNames.size());
-    //     Assertions.assertTrue(job.columnNames.contains("col4"));
-    //     Assertions.assertEquals(JobPriority.MID, job.priority);
-    //
-    //     job = midJobs.get(1);
-    //     Assertions.assertEquals("catalog4", job.catalogName);
-    //     Assertions.assertEquals("db4", job.dbName);
-    //     Assertions.assertEquals("mid2", job.tableName);
-    //     Assertions.assertEquals(1, job.columnNames.size());
-    //     Assertions.assertTrue(job.columnNames.contains("col5"));
-    //     Assertions.assertEquals(JobPriority.MID, job.priority);
-    //
-    //     new MockUp<ShowAutoAnalyzeJobsStmt>() {
-    //         @Mock
-    //         public String getPriority() {
-    //             return JobPriority.LOW.name().toUpperCase();
-    //         }
-    //     };
-    //     List<AutoAnalysisPendingJob> lowJobs = 
manager.showAutoPendingJobs(stmt);
-    //     Assertions.assertEquals(1, lowJobs.size());
-    //     job = lowJobs.get(0);
-    //     Assertions.assertEquals("catalog5", job.catalogName);
-    //     Assertions.assertEquals("db5", job.dbName);
-    //     Assertions.assertEquals("low1", job.tableName);
-    //     Assertions.assertEquals(2, job.columnNames.size());
-    //     Assertions.assertTrue(job.columnNames.contains("col6"));
-    //     Assertions.assertTrue(job.columnNames.contains("col7"));
-    //     Assertions.assertEquals(JobPriority.LOW, job.priority);
-    // }
+    @Test
+    public void testShowAutoJobs() {
+        AnalysisManager manager = new AnalysisManager();
+        TableName high1 = new TableName("catalog1", "db1", "high1");
+        TableName high2 = new TableName("catalog2", "db2", "high2");
+        TableName mid1 = new TableName("catalog3", "db3", "mid1");
+        TableName mid2 = new TableName("catalog4", "db4", "mid2");
+        TableName low1 = new TableName("catalog5", "db5", "low1");
+
+        manager.highPriorityJobs.put(high1, new HashSet<>());
+        manager.highPriorityJobs.get(high1).add(Pair.of("index1", "col1"));
+        manager.highPriorityJobs.get(high1).add(Pair.of("index2", "col2"));
+        manager.highPriorityJobs.put(high2, new HashSet<>());
+        manager.highPriorityJobs.get(high2).add(Pair.of("index1", "col3"));
+        manager.midPriorityJobs.put(mid1, new HashSet<>());
+        manager.midPriorityJobs.get(mid1).add(Pair.of("index1", "col4"));
+        manager.midPriorityJobs.put(mid2, new HashSet<>());
+        manager.midPriorityJobs.get(mid2).add(Pair.of("index1", "col5"));
+        manager.lowPriorityJobs.put(low1, new HashSet<>());
+        manager.lowPriorityJobs.get(low1).add(Pair.of("index1", "col6"));
+        manager.lowPriorityJobs.get(low1).add(Pair.of("index1", "col7"));
+
+        new MockUp<StatementBase>() {
+            @Mock
+            public boolean isAnalyzed() {
+                return true;
+            }
+        };
+        ShowAutoAnalyzeJobsStmt stmt = new ShowAutoAnalyzeJobsStmt(null, null);
+        List<AutoAnalysisPendingJob> autoAnalysisPendingJobs = 
manager.showAutoPendingJobs(stmt);
+        Assertions.assertEquals(5, autoAnalysisPendingJobs.size());
+        AutoAnalysisPendingJob job = autoAnalysisPendingJobs.get(0);
+        Assertions.assertEquals("catalog1", job.catalogName);
+        Assertions.assertEquals("db1", job.dbName);
+        Assertions.assertEquals("high1", job.tableName);
+        Assertions.assertEquals(2, job.columns.size());
+        Assertions.assertTrue(job.columns.contains(Pair.of("index1", "col1")));
+        Assertions.assertTrue(job.columns.contains(Pair.of("index2", "col2")));
+        Assertions.assertEquals(JobPriority.HIGH, job.priority);
+
+        job = autoAnalysisPendingJobs.get(1);
+        Assertions.assertEquals("catalog2", job.catalogName);
+        Assertions.assertEquals("db2", job.dbName);
+        Assertions.assertEquals("high2", job.tableName);
+        Assertions.assertEquals(1, job.columns.size());
+        Assertions.assertTrue(job.columns.contains(Pair.of("index1", "col3")));
+        Assertions.assertEquals(JobPriority.HIGH, job.priority);
+
+        job = autoAnalysisPendingJobs.get(2);
+        Assertions.assertEquals("catalog3", job.catalogName);
+        Assertions.assertEquals("db3", job.dbName);
+        Assertions.assertEquals("mid1", job.tableName);
+        Assertions.assertEquals(1, job.columns.size());
+        Assertions.assertTrue(job.columns.contains(Pair.of("index1", "col4")));
+        Assertions.assertEquals(JobPriority.MID, job.priority);
+
+        job = autoAnalysisPendingJobs.get(3);
+        Assertions.assertEquals("catalog4", job.catalogName);
+        Assertions.assertEquals("db4", job.dbName);
+        Assertions.assertEquals("mid2", job.tableName);
+        Assertions.assertEquals(1, job.columns.size());
+        Assertions.assertTrue(job.columns.contains(Pair.of("index1", "col5")));
+        Assertions.assertEquals(JobPriority.MID, job.priority);
+
+        job = autoAnalysisPendingJobs.get(4);
+        Assertions.assertEquals("catalog5", job.catalogName);
+        Assertions.assertEquals("db5", job.dbName);
+        Assertions.assertEquals("low1", job.tableName);
+        Assertions.assertEquals(2, job.columns.size());
+        Assertions.assertTrue(job.columns.contains(Pair.of("index1", "col6")));
+        Assertions.assertTrue(job.columns.contains(Pair.of("index1", "col7")));
+        Assertions.assertEquals(JobPriority.LOW, job.priority);
+
+        new MockUp<ShowAutoAnalyzeJobsStmt>() {
+            @Mock
+            public String getPriority() {
+                return JobPriority.HIGH.name().toUpperCase();
+            }
+        };
+        List<AutoAnalysisPendingJob> highJobs = 
manager.showAutoPendingJobs(stmt);
+        Assertions.assertEquals(2, highJobs.size());
+        job = highJobs.get(0);
+        Assertions.assertEquals("catalog1", job.catalogName);
+        Assertions.assertEquals("db1", job.dbName);
+        Assertions.assertEquals("high1", job.tableName);
+        Assertions.assertEquals(2, job.columns.size());
+        Assertions.assertTrue(job.columns.contains(Pair.of("index1", "col1")));
+        Assertions.assertTrue(job.columns.contains(Pair.of("index2", "col2")));
+        Assertions.assertEquals(JobPriority.HIGH, job.priority);
+
+        job = highJobs.get(1);
+        Assertions.assertEquals("catalog2", job.catalogName);
+        Assertions.assertEquals("db2", job.dbName);
+        Assertions.assertEquals("high2", job.tableName);
+        Assertions.assertEquals(1, job.columns.size());
+        Assertions.assertTrue(job.columns.contains(Pair.of("index1", "col3")));
+        Assertions.assertEquals(JobPriority.HIGH, job.priority);
+
+        new MockUp<ShowAutoAnalyzeJobsStmt>() {
+            @Mock
+            public String getPriority() {
+                return JobPriority.MID.name().toUpperCase();
+            }
+        };
+        List<AutoAnalysisPendingJob> midJobs = 
manager.showAutoPendingJobs(stmt);
+        Assertions.assertEquals(2, midJobs.size());
+        job = midJobs.get(0);
+        Assertions.assertEquals("catalog3", job.catalogName);
+        Assertions.assertEquals("db3", job.dbName);
+        Assertions.assertEquals("mid1", job.tableName);
+        Assertions.assertEquals(1, job.columns.size());
+        Assertions.assertTrue(job.columns.contains(Pair.of("index1", "col4")));
+        Assertions.assertEquals(JobPriority.MID, job.priority);
+
+        job = midJobs.get(1);
+        Assertions.assertEquals("catalog4", job.catalogName);
+        Assertions.assertEquals("db4", job.dbName);
+        Assertions.assertEquals("mid2", job.tableName);
+        Assertions.assertEquals(1, job.columns.size());
+        Assertions.assertTrue(job.columns.contains(Pair.of("index1", "col5")));
+        Assertions.assertEquals(JobPriority.MID, job.priority);
+
+        new MockUp<ShowAutoAnalyzeJobsStmt>() {
+            @Mock
+            public String getPriority() {
+                return JobPriority.LOW.name().toUpperCase();
+            }
+        };
+        List<AutoAnalysisPendingJob> lowJobs = 
manager.showAutoPendingJobs(stmt);
+        Assertions.assertEquals(1, lowJobs.size());
+        job = lowJobs.get(0);
+        Assertions.assertEquals("catalog5", job.catalogName);
+        Assertions.assertEquals("db5", job.dbName);
+        Assertions.assertEquals("low1", job.tableName);
+        Assertions.assertEquals(2, job.columns.size());
+        Assertions.assertTrue(job.columns.contains(Pair.of("index1", "col6")));
+        Assertions.assertTrue(job.columns.contains(Pair.of("index1", "col7")));
+        Assertions.assertEquals(JobPriority.LOW, job.priority);
+    }
 }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/statistics/FollowerColumnSenderTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/statistics/FollowerColumnSenderTest.java
index 7cbad753994..2a5ae531d1e 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/statistics/FollowerColumnSenderTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/statistics/FollowerColumnSenderTest.java
@@ -17,6 +17,11 @@
 
 package org.apache.doris.statistics;
 
+import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.OlapTable;
+import org.apache.doris.catalog.PrimitiveType;
+import org.apache.doris.catalog.TableIf;
+import org.apache.doris.common.Pair;
 import org.apache.doris.statistics.util.StatisticsUtil;
 import org.apache.doris.thrift.TQueryColumn;
 
@@ -26,6 +31,7 @@ import org.eclipse.jetty.util.BlockingArrayQueue;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
+import java.util.Collections;
 import java.util.Queue;
 import java.util.Set;
 
@@ -33,13 +39,30 @@ public class FollowerColumnSenderTest {
 
     @Test
     public void testGetNeedAnalyzeColumns() {
+        new MockUp<OlapTable>() {
+            @Mock
+            public Column getColumn(String name) {
+                return new Column("col", PrimitiveType.INT);
+            }
+
+            @Mock
+            public Set<Pair<String, String>> getColumnIndexPairs(Set<String> 
columns) {
+                return Collections.singleton(Pair.of("mockIndex", "mockCol"));
+            }
+        };
+
         new MockUp<StatisticsUtil>() {
             boolean[] result = {false, true, false, true, true};
             int i = 0;
             @Mock
-            public boolean needAnalyzeColumn(QueryColumn column) {
+            public boolean needAnalyzeColumn(TableIf table, Pair<String, 
String> column) {
                 return result[i++];
             }
+
+            @Mock
+            public TableIf findTable(long catalogId, long dbId, long tblId) {
+                return new OlapTable();
+            }
         };
         QueryColumn column1 = new QueryColumn(1, 2, 3, "col1");
         QueryColumn column2 = new QueryColumn(1, 2, 3, "col2");
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsAutoCollectorTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsAutoCollectorTest.java
index eef5832c816..6324624abac 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsAutoCollectorTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsAutoCollectorTest.java
@@ -17,95 +17,95 @@
 
 package org.apache.doris.statistics;
 
+import org.apache.doris.analysis.TableName;
 import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.Env;
 import org.apache.doris.catalog.OlapTable;
 import org.apache.doris.catalog.PrimitiveType;
-import org.apache.doris.catalog.TableIf;
-import org.apache.doris.catalog.Type;
 import org.apache.doris.common.Pair;
 import org.apache.doris.datasource.ExternalTable;
 import org.apache.doris.datasource.hive.HMSExternalTable;
 import org.apache.doris.datasource.hive.HMSExternalTable.DLAType;
 import org.apache.doris.datasource.jdbc.JdbcExternalTable;
-import org.apache.doris.statistics.util.StatisticsUtil;
 
-import com.google.common.collect.Lists;
 import mockit.Mock;
 import mockit.MockUp;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Map.Entry;
 import java.util.Set;
 
 public class StatisticsAutoCollectorTest {
 
-    // @Test
-    // public void testFetchJob() {
-    //     AnalysisManager manager = new AnalysisManager();
-    //     TableName high1 = new TableName("catalog", "db", "high1");
-    //     TableName high2 = new TableName("catalog", "db", "high2");
-    //     TableName mid1 = new TableName("catalog", "db", "mid1");
-    //     TableName mid2 = new TableName("catalog", "db", "mid2");
-    //     TableName low1 = new TableName("catalog", "db", "low1");
-    //
-    //     manager.highPriorityJobs.put(high1, new HashSet<String>());
-    //     manager.highPriorityJobs.get(high1).add("col1");
-    //     manager.highPriorityJobs.get(high1).add("col2");
-    //     manager.highPriorityJobs.put(high2, new HashSet<String>());
-    //     manager.highPriorityJobs.get(high2).add("col3");
-    //     manager.midPriorityJobs.put(mid1, new HashSet<String>());
-    //     manager.midPriorityJobs.get(mid1).add("col4");
-    //     manager.midPriorityJobs.put(mid2, new HashSet<String>());
-    //     manager.midPriorityJobs.get(mid2).add("col5");
-    //     manager.lowPriorityJobs.put(low1, new HashSet<String>());
-    //     manager.lowPriorityJobs.get(low1).add("col6");
-    //     manager.lowPriorityJobs.get(low1).add("col7");
-    //
-    //
-    //     new MockUp<Env>() {
-    //         @Mock
-    //         public AnalysisManager getAnalysisManager() {
-    //             return manager;
-    //         }
-    //     };
-    //     StatisticsAutoCollector collector = new StatisticsAutoCollector();
-    //     Pair<Entry<TableName, Set<String>>, JobPriority> job = 
collector.getJob();
-    //     Assertions.assertEquals(high1, job.first.getKey());
-    //     Assertions.assertEquals(2, job.first.getValue().size());
-    //     Assertions.assertTrue(job.first.getValue().contains("col1"));
-    //     Assertions.assertTrue(job.first.getValue().contains("col2"));
-    //     Assertions.assertEquals(JobPriority.HIGH, job.second);
-    //
-    //     job = collector.getJob();
-    //     Assertions.assertEquals(high2, job.first.getKey());
-    //     Assertions.assertEquals(1, job.first.getValue().size());
-    //     Assertions.assertTrue(job.first.getValue().contains("col3"));
-    //     Assertions.assertEquals(JobPriority.HIGH, job.second);
-    //
-    //     job = collector.getJob();
-    //     Assertions.assertEquals(mid1, job.first.getKey());
-    //     Assertions.assertEquals(1, job.first.getValue().size());
-    //     Assertions.assertTrue(job.first.getValue().contains("col4"));
-    //     Assertions.assertEquals(JobPriority.MID, job.second);
-    //
-    //     job = collector.getJob();
-    //     Assertions.assertEquals(mid2, job.first.getKey());
-    //     Assertions.assertEquals(1, job.first.getValue().size());
-    //     Assertions.assertTrue(job.first.getValue().contains("col5"));
-    //     Assertions.assertEquals(JobPriority.MID, job.second);
-    //
-    //     job = collector.getJob();
-    //     Assertions.assertEquals(low1, job.first.getKey());
-    //     Assertions.assertEquals(2, job.first.getValue().size());
-    //     Assertions.assertTrue(job.first.getValue().contains("col6"));
-    //     Assertions.assertTrue(job.first.getValue().contains("col7"));
-    //     Assertions.assertEquals(JobPriority.LOW, job.second);
-    //
-    //     job = collector.getJob();
-    //     Assertions.assertNull(job);
-    // }
+    @Test
+    public void testFetchJob() {
+        AnalysisManager manager = new AnalysisManager();
+        TableName high1 = new TableName("catalog", "db", "high1");
+        TableName high2 = new TableName("catalog", "db", "high2");
+        TableName mid1 = new TableName("catalog", "db", "mid1");
+        TableName mid2 = new TableName("catalog", "db", "mid2");
+        TableName low1 = new TableName("catalog", "db", "low1");
+
+        manager.highPriorityJobs.put(high1, new HashSet<>());
+        manager.highPriorityJobs.get(high1).add(Pair.of("index1", "col1"));
+        manager.highPriorityJobs.get(high1).add(Pair.of("index1", "col2"));
+        manager.highPriorityJobs.put(high2, new HashSet<>());
+        manager.highPriorityJobs.get(high2).add(Pair.of("index1", "col3"));
+        manager.midPriorityJobs.put(mid1, new HashSet<>());
+        manager.midPriorityJobs.get(mid1).add(Pair.of("index1", "col4"));
+        manager.midPriorityJobs.put(mid2, new HashSet<>());
+        manager.midPriorityJobs.get(mid2).add(Pair.of("index1", "col5"));
+        manager.lowPriorityJobs.put(low1, new HashSet<>());
+        manager.lowPriorityJobs.get(low1).add(Pair.of("index1", "col6"));
+        manager.lowPriorityJobs.get(low1).add(Pair.of("index1", "col7"));
+
+
+        new MockUp<Env>() {
+            @Mock
+            public AnalysisManager getAnalysisManager() {
+                return manager;
+            }
+        };
+        StatisticsAutoCollector collector = new StatisticsAutoCollector();
+        Pair<Entry<TableName, Set<Pair<String, String>>>, JobPriority> job = 
collector.getJob();
+        Assertions.assertEquals(high1, job.first.getKey());
+        Assertions.assertEquals(2, job.first.getValue().size());
+        Assertions.assertTrue(job.first.getValue().contains(Pair.of("index1", 
"col1")));
+        Assertions.assertTrue(job.first.getValue().contains(Pair.of("index1", 
"col2")));
+        Assertions.assertEquals(JobPriority.HIGH, job.second);
+
+        job = collector.getJob();
+        Assertions.assertEquals(high2, job.first.getKey());
+        Assertions.assertEquals(1, job.first.getValue().size());
+        Assertions.assertTrue(job.first.getValue().contains(Pair.of("index1", 
"col3")));
+        Assertions.assertEquals(JobPriority.HIGH, job.second);
+
+        job = collector.getJob();
+        Assertions.assertEquals(mid1, job.first.getKey());
+        Assertions.assertEquals(1, job.first.getValue().size());
+        Assertions.assertTrue(job.first.getValue().contains(Pair.of("index1", 
"col4")));
+        Assertions.assertEquals(JobPriority.MID, job.second);
+
+        job = collector.getJob();
+        Assertions.assertEquals(mid2, job.first.getKey());
+        Assertions.assertEquals(1, job.first.getValue().size());
+        Assertions.assertTrue(job.first.getValue().contains(Pair.of("index1", 
"col5")));
+        Assertions.assertEquals(JobPriority.MID, job.second);
+
+        job = collector.getJob();
+        Assertions.assertEquals(low1, job.first.getKey());
+        Assertions.assertEquals(2, job.first.getValue().size());
+        Assertions.assertTrue(job.first.getValue().contains(Pair.of("index1", 
"col6")));
+        Assertions.assertTrue(job.first.getValue().contains(Pair.of("index1", 
"col7")));
+        Assertions.assertEquals(JobPriority.LOW, job.second);
+
+        job = collector.getJob();
+        Assertions.assertNull(job);
+    }
 
     @Test
     public void testSupportAutoAnalyze() {
@@ -138,44 +138,4 @@ public class StatisticsAutoCollectorTest {
         ExternalTable hiveExternalTable = new HMSExternalTable(1, "hmsTable", 
"hmsDb", null);
         Assertions.assertTrue(collector.supportAutoAnalyze(hiveExternalTable));
     }
-
-    @Test
-    public void testSkipWideTable() {
-
-        TableIf tableIf = new OlapTable();
-
-        new MockUp<OlapTable>() {
-            @Mock
-            public List<Column> getBaseSchema() {
-                return Lists.newArrayList(new Column("col1", Type.INT), new 
Column("col2", Type.INT));
-            }
-
-            @Mock
-            public List<Pair<String, String>> getColumnIndexPairs(Set<String> 
columns) {
-                ArrayList<Pair<String, String>> list = Lists.newArrayList();
-                list.add(Pair.of("1", "1"));
-                return list;
-            }
-        };
-
-        new MockUp<StatisticsUtil>() {
-            int count = 0;
-            int[] thresholds = {1, 10};
-
-            @Mock
-            public TableIf findTable(long catalogName, long dbName, long 
tblName) {
-                return tableIf;
-            }
-
-            @Mock
-            public int getAutoAnalyzeTableWidthThreshold() {
-                return thresholds[count++];
-            }
-        };
-
-        AnalysisInfo analysisInfo = new AnalysisInfoBuilder().build();
-        StatisticsAutoCollector statisticsAutoCollector = new 
StatisticsAutoCollector();
-        
Assertions.assertNull(statisticsAutoCollector.getNeedAnalyzeColumns(analysisInfo));
-        
Assertions.assertNotNull(statisticsAutoCollector.getNeedAnalyzeColumns(analysisInfo));
-    }
 }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsJobAppenderTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsJobAppenderTest.java
index 6bf2539e9a7..e3255ab23a0 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsJobAppenderTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/statistics/StatisticsJobAppenderTest.java
@@ -17,190 +17,265 @@
 
 package org.apache.doris.statistics;
 
-// import org.apache.doris.analysis.TableName;
-// import org.apache.doris.catalog.Column;
-// import org.apache.doris.catalog.Database;
-// import org.apache.doris.catalog.DatabaseIf;
-// import org.apache.doris.catalog.Env;
-// import org.apache.doris.catalog.OlapTable;
-// import org.apache.doris.catalog.PrimitiveType;
-// import org.apache.doris.catalog.Table;
-// import org.apache.doris.catalog.TableIf;
-// import org.apache.doris.common.DdlException;
-// import org.apache.doris.common.Pair;
-// import org.apache.doris.datasource.InternalCatalog;
-// import org.apache.doris.statistics.util.StatisticsUtil;
-//
-// import mockit.Mock;
-// import mockit.MockUp;
-// import org.junit.jupiter.api.Assertions;
-// import org.junit.jupiter.api.Test;
-//
-// import java.util.ArrayList;
-// import java.util.HashMap;
-// import java.util.HashSet;
-// import java.util.List;
-// import java.util.Map;
-// import java.util.Queue;
-// import java.util.Set;
-// import java.util.UUID;
-// import java.util.concurrent.ArrayBlockingQueue;
+import org.apache.doris.analysis.TableName;
+import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.Database;
+import org.apache.doris.catalog.DatabaseIf;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.OlapTable;
+import org.apache.doris.catalog.PrimitiveType;
+import org.apache.doris.catalog.Table;
+import org.apache.doris.catalog.TableIf;
+import org.apache.doris.catalog.Type;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.common.Pair;
+import org.apache.doris.datasource.InternalCatalog;
+import org.apache.doris.statistics.util.StatisticsUtil;
+
+import com.google.common.collect.Lists;
+import mockit.Mock;
+import mockit.MockUp;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ArrayBlockingQueue;
 
 public class StatisticsJobAppenderTest {
 
-    // @Test
-    // public void testAppendQueryColumnToHighAndMidJobMap() throws 
DdlException {
-    //     InternalCatalog testCatalog = new InternalCatalog();
-    //     Database db = new Database(100, "testDb");
-    //     testCatalog.unprotectCreateDb(db);
-    //     Column column1 = new Column("placeholder", PrimitiveType.INT);
-    //     List<Column> schema = new ArrayList<>();
-    //     schema.add(column1);
-    //     OlapTable table1 = new OlapTable(200, "testTable", schema, null, 
null, null);
-    //     OlapTable table2 = new OlapTable(200, "testTable2", schema, null, 
null, null);
-    //     OlapTable table3 = new OlapTable(200, "testTable3", schema, null, 
null, null);
-    //     new MockUp<StatisticsUtil>() {
-    //         int i = 0;
-    //         Table[] tables = {table1, table2, table1, table3, table2};
-    //
-    //         @Mock
-    //         public boolean needAnalyzeColumn(QueryColumn column) {
-    //             return true;
-    //         }
-    //
-    //         @Mock
-    //         public TableIf findTable(long catalogId, long dbId, long tblId) 
{
-    //             return tables[i++];
-    //         }
-    //     };
-    //
-    //     new MockUp<Table>() {
-    //         @Mock
-    //         public DatabaseIf getDatabase() {
-    //             return db;
-    //         }
-    //     };
-    //
-    //     Queue<QueryColumn> testQueue = new ArrayBlockingQueue<>(100);
-    //     Map<TableName, Set<Pair<String, String>>> testMap = new 
HashMap<TableName, Set<Pair<String, String>>>();
-    //     QueryColumn high1 = new QueryColumn(10, 20, 30, "high1");
-    //     testQueue.add(high1);
-    //
-    //     StatisticsJobAppender appender = new StatisticsJobAppender();
-    //     appender.appendColumnsToJobs(testQueue, testMap);
-    //     Assertions.assertEquals(1, testMap.size());
-    //     Assertions.assertEquals(1, testMap.values().size());
-    //     Assertions.assertTrue(testMap.get(new TableName("internal", 
"testDb", "testTable")).contains("high1"));
-    //
-    //     QueryColumn high2 = new QueryColumn(10, 20, 30, "high2");
-    //     QueryColumn high3 = new QueryColumn(10, 20, 30, "high3");
-    //     testQueue.add(high2);
-    //     testQueue.add(high3);
-    //     appender.appendColumnsToJobs(testQueue, testMap);
-    //     Assertions.assertEquals(2, testMap.size());
-    //
-    //     Set<String> table1Column = testMap.get(new TableName("internal", 
"testDb", "testTable"));
-    //     Assertions.assertEquals(2, table1Column.size());
-    //     Assertions.assertTrue(table1Column.contains("high1"));
-    //     Assertions.assertTrue(table1Column.contains("high3"));
-    //
-    //     Set<String> table2Column = testMap.get(new TableName("internal", 
"testDb", "testTable2"));
-    //     Assertions.assertEquals(1, table2Column.size());
-    //     Assertions.assertTrue(table2Column.contains("high2"));
-    //
-    //     for (int i = 0; i < StatisticsJobAppender.JOB_MAP_SIZE - 2; i++) {
-    //         testMap.put(new TableName("a", "b", 
UUID.randomUUID().toString()), new HashSet<>());
-    //     }
-    //     Assertions.assertEquals(StatisticsJobAppender.JOB_MAP_SIZE, 
testMap.size());
-    //
-    //     QueryColumn high4 = new QueryColumn(10, 20, 30, "high4");
-    //     testQueue.add(high4);
-    //     appender.appendColumnsToJobs(testQueue, testMap);
-    //     Assertions.assertEquals(StatisticsJobAppender.JOB_MAP_SIZE, 
testMap.size());
-    //
-    //     QueryColumn high5 = new QueryColumn(10, 20, 30, "high5");
-    //     testQueue.add(high5);
-    //     appender.appendColumnsToJobs(testQueue, testMap);
-    //     table2Column = testMap.get(new TableName("internal", "testDb", 
"testTable2"));
-    //     Assertions.assertEquals(2, table2Column.size());
-    //     Assertions.assertTrue(table2Column.contains("high2"));
-    //     Assertions.assertTrue(table2Column.contains("high5"));
-    // }
-    //
-    // @Test
-    // public void testAppendQueryColumnToLowJobMap() throws DdlException {
-    //     InternalCatalog testCatalog = new InternalCatalog();
-    //     int id = 10;
-    //     for (int i = 0; i < 70; i++) {
-    //         Database db = new Database(id++, "testDb" + i);
-    //         testCatalog.unprotectCreateDb(db);
-    //         Column column1 = new Column("placeholder", PrimitiveType.INT);
-    //         List<Column> schema = new ArrayList<>();
-    //         schema.add(column1);
-    //         OlapTable table1 = new OlapTable(id++, "testTable" + id + "_1", 
schema, null, null, null);
-    //         OlapTable table2 = new OlapTable(id++, "testTable" + id + "_1", 
schema, null, null, null);
-    //         db.createTableWithLock(table1, true, false);
-    //         db.createTableWithLock(table2, true, false);
-    //     }
-    //
-    //     new MockUp<Env>() {
-    //         @Mock
-    //         public InternalCatalog getCurrentInternalCatalog() {
-    //             return testCatalog;
-    //         }
-    //     };
-    //
-    //     Map<TableName, Set<String>> testMap = new HashMap<TableName, 
Set<String>>();
-    //     StatisticsJobAppender appender = new StatisticsJobAppender();
-    //     appender.appendToLowJobs(testMap);
-    //     Assertions.assertEquals(100, testMap.size());
-    //     testMap.clear();
-    //     appender.appendToLowJobs(testMap);
-    //     Assertions.assertEquals(40, testMap.size());
-    //
-    //     for (int i = 0; i < StatisticsJobAppender.JOB_MAP_SIZE; i++) {
-    //         Database db = new Database(id++, "testDb" + i);
-    //         testCatalog.unprotectCreateDb(db);
-    //         Column column1 = new Column("placeholder", PrimitiveType.INT);
-    //         List<Column> schema = new ArrayList<>();
-    //         schema.add(column1);
-    //         OlapTable table1 = new OlapTable(id++, "testTable" + id + "_1", 
schema, null, null, null);
-    //         OlapTable table2 = new OlapTable(id++, "testTable" + id + "_1", 
schema, null, null, null);
-    //         db.createTableWithLock(table1, true, false);
-    //         db.createTableWithLock(table2, true, false);
-    //     }
-    //
-    //     testMap.clear();
-    //     appender.setLastRoundFinishTime(0);
-    //     appender.appendToLowJobs(testMap);
-    //     appender.setLastRoundFinishTime(0);
-    //     appender.appendToLowJobs(testMap);
-    //     appender.setLastRoundFinishTime(0);
-    //     appender.appendToLowJobs(testMap);
-    //     appender.setLastRoundFinishTime(0);
-    //     appender.appendToLowJobs(testMap);
-    //     appender.setLastRoundFinishTime(0);
-    //     appender.appendToLowJobs(testMap);
-    //     appender.setLastRoundFinishTime(0);
-    //     appender.appendToLowJobs(testMap);
-    //     appender.setLastRoundFinishTime(0);
-    //     appender.appendToLowJobs(testMap);
-    //     appender.setLastRoundFinishTime(0);
-    //     appender.appendToLowJobs(testMap);
-    //     appender.setLastRoundFinishTime(0);
-    //     appender.appendToLowJobs(testMap);
-    //     appender.setLastRoundFinishTime(0);
-    //     appender.appendToLowJobs(testMap);
-    //     appender.setLastRoundFinishTime(0);
-    //     appender.appendToLowJobs(testMap);
-    //     appender.setLastRoundFinishTime(0);
-    //     appender.appendToLowJobs(testMap);
-    //     appender.setLastRoundFinishTime(0);
-    //     appender.appendToLowJobs(testMap);
-    //     appender.setLastRoundFinishTime(0);
-    //     appender.appendToLowJobs(testMap);
-    //     appender.setLastRoundFinishTime(0);
-    //     appender.appendToLowJobs(testMap);
-    //     Assertions.assertEquals(StatisticsJobAppender.JOB_MAP_SIZE, 
testMap.size());
-    // }
+    @Test
+    public void testAppendQueryColumnToHighAndMidJobMap() throws DdlException {
+        InternalCatalog testCatalog = new InternalCatalog();
+        Database db = new Database(100, "testDb");
+        testCatalog.unprotectCreateDb(db);
+        Column column1 = new Column("placeholder", PrimitiveType.INT);
+        List<Column> schema = new ArrayList<>();
+        schema.add(column1);
+        OlapTable table1 = new OlapTable(200, "testTable", schema, null, null, 
null);
+        OlapTable table2 = new OlapTable(200, "testTable2", schema, null, 
null, null);
+        OlapTable table3 = new OlapTable(200, "testTable3", schema, null, 
null, null);
+        new MockUp<StatisticsUtil>() {
+            int i = 0;
+            Table[] tables = {table1, table2, table1, table3, table2};
+
+            @Mock
+            public boolean needAnalyzeColumn(TableIf table, Pair<String, 
String> column) {
+                return true;
+            }
+
+            @Mock
+            public TableIf findTable(long catalogId, long dbId, long tblId) {
+                return tables[i++];
+            }
+        };
+
+        new MockUp<Table>() {
+            @Mock
+            public DatabaseIf getDatabase() {
+                return db;
+            }
+
+            @Mock
+            public Column getColumn(String name) {
+                return new Column("mockCol", Type.INT);
+            }
+        };
+
+        new MockUp<OlapTable>() {
+            @Mock
+            public Set<Pair<String, String>> getColumnIndexPairs(Set<String> 
columns) {
+                String column = columns.iterator().next();
+                return Collections.singleton(Pair.of("mockIndex", column));
+            }
+        };
+
+        Queue<QueryColumn> testQueue = new ArrayBlockingQueue<>(100);
+        Map<TableName, Set<Pair<String, String>>> testMap = new HashMap<>();
+        QueryColumn high1 = new QueryColumn(10, 20, 30, "high1");
+        testQueue.add(high1);
+
+        StatisticsJobAppender appender = new StatisticsJobAppender();
+        appender.appendColumnsToJobs(testQueue, testMap);
+        Assertions.assertEquals(1, testMap.size());
+        Assertions.assertEquals(1, testMap.values().size());
+        Assertions.assertTrue(testMap.get(new TableName("internal", "testDb", 
"testTable")).contains(Pair.of("mockIndex", "high1")));
+
+        QueryColumn high2 = new QueryColumn(10, 20, 30, "high2");
+        QueryColumn high3 = new QueryColumn(10, 20, 30, "high3");
+        testQueue.add(high2);
+        testQueue.add(high3);
+        appender.appendColumnsToJobs(testQueue, testMap);
+        Assertions.assertEquals(2, testMap.size());
+
+        Set<Pair<String, String>> table1Column = testMap.get(new 
TableName("internal", "testDb", "testTable"));
+        Assertions.assertEquals(2, table1Column.size());
+        Assertions.assertTrue(table1Column.contains(Pair.of("mockIndex", 
"high1")));
+        Assertions.assertTrue(table1Column.contains(Pair.of("mockIndex", 
"high3")));
+
+        Set<Pair<String, String>> table2Column = testMap.get(new 
TableName("internal", "testDb", "testTable2"));
+        Assertions.assertEquals(1, table2Column.size());
+        Assertions.assertTrue(table2Column.contains(Pair.of("mockIndex", 
"high2")));
+
+        for (int i = 0; i < StatisticsJobAppender.JOB_MAP_SIZE - 2; i++) {
+            testMap.put(new TableName("a", "b", UUID.randomUUID().toString()), 
new HashSet<>());
+        }
+        Assertions.assertEquals(StatisticsJobAppender.JOB_MAP_SIZE, 
testMap.size());
+
+        QueryColumn high4 = new QueryColumn(10, 20, 30, "high4");
+        testQueue.add(high4);
+        appender.appendColumnsToJobs(testQueue, testMap);
+        Assertions.assertEquals(StatisticsJobAppender.JOB_MAP_SIZE, 
testMap.size());
+
+        QueryColumn high5 = new QueryColumn(10, 20, 30, "high5");
+        testQueue.add(high5);
+        appender.appendColumnsToJobs(testQueue, testMap);
+        table2Column = testMap.get(new TableName("internal", "testDb", 
"testTable2"));
+        Assertions.assertEquals(2, table2Column.size());
+        Assertions.assertTrue(table2Column.contains(Pair.of("mockIndex", 
"high2")));
+        Assertions.assertTrue(table2Column.contains(Pair.of("mockIndex", 
"high5")));
+    }
+
+    @Test
+    public void testAppendQueryColumnToLowJobMap() throws DdlException {
+        InternalCatalog testCatalog = new InternalCatalog();
+        int id = 10;
+        for (int i = 0; i < 70; i++) {
+            Database db = new Database(id++, "testDb" + i);
+            testCatalog.unprotectCreateDb(db);
+            Column column1 = new Column("placeholder", PrimitiveType.INT);
+            List<Column> schema = new ArrayList<>();
+            schema.add(column1);
+            OlapTable table1 = new OlapTable(id++, "testTable" + id + "_1", 
schema, null, null, null);
+            OlapTable table2 = new OlapTable(id++, "testTable" + id + "_1", 
schema, null, null, null);
+            db.createTableWithLock(table1, true, false);
+            db.createTableWithLock(table2, true, false);
+        }
+
+        new MockUp<Env>() {
+            @Mock
+            public InternalCatalog getCurrentInternalCatalog() {
+                return testCatalog;
+            }
+        };
+
+        new MockUp<OlapTable>() {
+            @Mock
+            public List<Column> getBaseSchema() {
+                return Lists.newArrayList();
+            }
+
+            @Mock
+            public Set<Pair<String, String>> getColumnIndexPairs(Set<String> 
columns) {
+                return Collections.singleton(Pair.of("mockIndex", 
"mockColumn"));
+            }
+        };
+
+        Map<TableName, Set<Pair<String, String>>> testMap = new HashMap<>();
+        StatisticsJobAppender appender = new StatisticsJobAppender();
+        appender.appendToLowJobs(testMap);
+        Assertions.assertEquals(100, testMap.size());
+        testMap.clear();
+        appender.appendToLowJobs(testMap);
+        Assertions.assertEquals(40, testMap.size());
+
+        for (int i = 0; i < StatisticsJobAppender.JOB_MAP_SIZE; i++) {
+            Database db = new Database(id++, "testDb" + i);
+            testCatalog.unprotectCreateDb(db);
+            Column column1 = new Column("placeholder", PrimitiveType.INT);
+            List<Column> schema = new ArrayList<>();
+            schema.add(column1);
+            OlapTable table1 = new OlapTable(id++, "testTable" + id + "_1", 
schema, null, null, null);
+            OlapTable table2 = new OlapTable(id++, "testTable" + id + "_1", 
schema, null, null, null);
+            db.createTableWithLock(table1, true, false);
+            db.createTableWithLock(table2, true, false);
+        }
+
+        testMap.clear();
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        Assertions.assertEquals(StatisticsJobAppender.JOB_MAP_SIZE, 
testMap.size());
+    }
+
+    @Test
+    public void testSkipWideTable() throws DdlException {
+        InternalCatalog testCatalog = new InternalCatalog();
+        int id = 10;
+        Database db = new Database(id++, "testDb");
+        testCatalog.unprotectCreateDb(db);
+        Column column1 = new Column("placeholder", PrimitiveType.INT);
+        List<Column> schema = new ArrayList<>();
+        schema.add(column1);
+        OlapTable table1 = new OlapTable(id++, "testTable" + id + "_1", 
schema, null, null, null);
+        db.createTableWithLock(table1, true, false);
+        new MockUp<Env>() {
+            @Mock
+            public InternalCatalog getCurrentInternalCatalog() {
+                return testCatalog;
+            }
+        };
+        new MockUp<OlapTable>() {
+            @Mock
+            public List<Column> getBaseSchema() {
+                return Lists.newArrayList(new Column("col1", Type.INT), new 
Column("col2", Type.INT));
+            }
+
+            @Mock
+            public Set<Pair<String, String>> getColumnIndexPairs(Set<String> 
columns) {
+                return Collections.singleton(Pair.of("1", "1"));
+            }
+        };
+
+        new MockUp<StatisticsUtil>() {
+            int count = 0;
+            int[] thresholds = {1, 10};
+
+            @Mock
+            public int getAutoAnalyzeTableWidthThreshold() {
+                return thresholds[count++];
+            }
+        };
+        Map<TableName, Set<Pair<String, String>>> testMap = new HashMap<>();
+        StatisticsJobAppender appender = new StatisticsJobAppender();
+        appender.appendToLowJobs(testMap);
+        Assertions.assertEquals(0, testMap.size());
+        appender.setLastRoundFinishTime(0);
+        appender.appendToLowJobs(testMap);
+        Assertions.assertEquals(1, testMap.size());
+    }
 }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/statistics/TableStatsMetaTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/statistics/TableStatsMetaTest.java
index b03ca72b6d0..10e1973aa33 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/statistics/TableStatsMetaTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/statistics/TableStatsMetaTest.java
@@ -19,8 +19,6 @@ package org.apache.doris.statistics;
 
 import org.apache.doris.catalog.OlapTable;
 
-import mockit.Mock;
-import mockit.MockUp;
 import mockit.Mocked;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
@@ -31,15 +29,9 @@ class TableStatsMetaTest {
 
     @Test
     void update(@Mocked OlapTable table) {
-        new MockUp<OlapTable>() {
-            @Mock
-            public long getRowCount() {
-                return 4;
-            }
-        };
         TableStatsMeta tableStatsMeta = new TableStatsMeta();
-        AnalysisInfo jobInfo = new AnalysisInfoBuilder().setJobColumns(new 
HashSet<>())
-                .setColName("col1").build();
+        AnalysisInfo jobInfo = new AnalysisInfoBuilder().setRowCount(4)
+                .setJobColumns(new HashSet<>()).setColName("col1").build();
         tableStatsMeta.update(jobInfo, table);
         Assertions.assertEquals(4, tableStatsMeta.rowCount);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to