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

morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new e41a7fbe85e [chore](fe) clean some code (#62171)
e41a7fbe85e is described below

commit e41a7fbe85e49f3cd97fc7f1009db8e1baab4564
Author: morrySnow <[email protected]>
AuthorDate: Wed Apr 8 14:51:25 2026 +0800

    [chore](fe) clean some code (#62171)
---
 .../java/org/apache/doris/analysis/ParseNode.java  |  13 --
 .../java/org/apache/doris/analysis/Separator.java  |  51 +-----
 .../org/apache/doris/analysis/StatementBase.java   |  25 +--
 .../org/apache/doris/analysis/StorageBackend.java  |  42 +----
 .../org/apache/doris/analysis/TableSample.java     |  16 +-
 .../java/org/apache/doris/catalog/Database.java    |  47 ------
 .../java/org/apache/doris/catalog/DatabaseIf.java  |  27 ----
 .../org/apache/doris/catalog/TableIndexes.java     |   9 +-
 .../org/apache/doris/datasource/CatalogIf.java     |   3 -
 .../apache/doris/datasource/ExternalCatalog.java   |   1 +
 .../apache/doris/datasource/ExternalDatabase.java  |   5 -
 .../main/java/org/apache/doris/load/ExportJob.java |   3 +-
 .../java/org/apache/doris/qe/AuditLogHelper.java   |   2 +-
 .../doris/statistics/util/StatisticsUtil.java      | 176 +--------------------
 .../load/routineload/RoutineLoadManagerTest.java   |   6 -
 .../doris/statistics/util/StatisticsUtilTest.java  |  30 ----
 16 files changed, 14 insertions(+), 442 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ParseNode.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ParseNode.java
index 09c495ba8ce..7e3e2de1276 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ParseNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ParseNode.java
@@ -20,19 +20,6 @@
 
 package org.apache.doris.analysis;
 
-import org.apache.doris.common.UserException;
-
 public interface ParseNode {
-    /**
-     * Perform semantic analysis of node and all of its children.
-     * Throws exception if any errors found.
-     *
-     */
-    void analyze() throws UserException;
-
-    /**
-     * @return SQL syntax corresponding to this node.
-     */
-    String toSql();
 
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/Separator.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/Separator.java
index 76be1710e2e..67515eaca5c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/Separator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/Separator.java
@@ -23,7 +23,7 @@ import com.google.common.base.Strings;
 
 import java.io.StringWriter;
 
-public class Separator implements ParseNode {
+public class Separator {
     private static final String HEX_STRING = "0123456789ABCDEF";
 
     private final String oriSeparator;
@@ -63,19 +63,10 @@ public class Separator implements ParseNode {
         return (byte) HEX_STRING.indexOf(c);
     }
 
-    @Override
     public void analyze() throws AnalysisException {
         this.separator = convertSeparator(oriSeparator);
     }
 
-    public void analyze(boolean isLine) throws AnalysisException {
-        if (isLine) {
-            this.separator = convertLineDelimiter(oriSeparator);
-        } else {
-            this.separator = convertSeparator(oriSeparator);
-        }
-    }
-
     public static String convertSeparator(String originStr) throws 
AnalysisException {
         if (Strings.isNullOrEmpty(originStr)) {
             throw new AnalysisException("Column separator is null or empty");
@@ -108,38 +99,6 @@ public class Separator implements ParseNode {
         }
     }
 
-    private static String convertLineDelimiter(String originStr) throws 
AnalysisException {
-        if (Strings.isNullOrEmpty(originStr)) {
-            throw new AnalysisException("Line delimiter is null or empty");
-        }
-
-        if (originStr.toUpperCase().startsWith("\\X")) {
-            // convert \x01\x02\x0a to 01020a
-            String hexStr = originStr.replaceAll("(?i)\\\\X", "");
-            // check hex str
-            if (hexStr.isEmpty()) {
-                throw new AnalysisException("Hex str is empty");
-            }
-            for (char hexChar : hexStr.toUpperCase().toCharArray()) {
-                if (HEX_STRING.indexOf(hexChar) == -1) {
-                    throw new AnalysisException("Hex str format error");
-                }
-            }
-            if (hexStr.length() % 2 != 0) {
-                throw new AnalysisException("Hex str length error");
-            }
-
-            // transform to separator
-            StringWriter writer = new StringWriter();
-            for (byte b : hexStrToBytes(hexStr)) {
-                writer.append((char) b);
-            }
-            return writer.toString();
-        } else {
-            return unescape(originStr);
-        }
-    }
-
     // unescape some invisible string literal to char, such as "/t" to char 
'/t'
     private static String unescape(String orig) {
         StringBuilder sb = new StringBuilder();
@@ -185,14 +144,8 @@ public class Separator implements ParseNode {
         return sb.toString();
     }
 
-    public String toSql() {
-        StringBuilder sb = new StringBuilder();
-        sb.append("'").append(oriSeparator).append("'");
-        return sb.toString();
-    }
-
     @Override
     public String toString() {
-        return toSql();
+        return "'" + oriSeparator + "'";
     }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/StatementBase.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/StatementBase.java
index 1ac8985f51a..568e54c83c4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/StatementBase.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/StatementBase.java
@@ -20,7 +20,6 @@
 
 package org.apache.doris.analysis;
 
-import org.apache.doris.common.UserException;
 import org.apache.doris.qe.OriginStatement;
 
 import com.google.common.base.Preconditions;
@@ -28,7 +27,7 @@ import com.google.common.base.Preconditions;
 import java.util.Collections;
 import java.util.List;
 
-public abstract class StatementBase implements ParseNode {
+public abstract class StatementBase {
     // Set this variable if this QueryStmt is the top level query from an 
EXPLAIN <query>
     protected ExplainOptions explainOptions = null;
     private OriginStatement origStmt;
@@ -44,18 +43,6 @@ public abstract class StatementBase implements ParseNode {
         explainOptions = other.explainOptions;
     }
 
-    /**
-     * Analyzes the statement and throws an AnalysisException if analysis 
fails. A failure
-     * could be due to a problem with the statement or because one or more 
tables/views
-     * were missing from the catalog.
-     * It is up to the analysis() implementation to ensure the maximum number 
of missing
-     * tables/views get collected in the Analyzer before failing analyze().
-     * Should call the method firstly when override the method, the analyzer 
param should be
-     * the one which statement would use.
-     */
-    public void analyze() throws UserException {
-    }
-
     public void setIsExplain(ExplainOptions options) {
         this.explainOptions = options;
     }
@@ -76,16 +63,6 @@ public abstract class StatementBase implements ParseNode {
         return this.isPrepared;
     }
 
-    /*
-     * Print SQL syntax corresponding to this node.
-     *
-     * @see org.apache.doris.parser.ParseNode#toSql()
-     */
-    @Override
-    public String toSql() {
-        return "";
-    }
-
     public StmtType stmtType() {
         return StmtType.OTHER;
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/StorageBackend.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/StorageBackend.java
index 312e6de0f79..e1f40e10b52 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/StorageBackend.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/StorageBackend.java
@@ -21,7 +21,6 @@ import org.apache.doris.common.AnalysisException;
 import org.apache.doris.common.FeNameFormat;
 import org.apache.doris.common.NotImplementedException;
 import org.apache.doris.common.UserException;
-import org.apache.doris.common.util.DatasourcePrintableMap;
 import org.apache.doris.thrift.TStorageBackendType;
 
 import com.google.common.base.Strings;
@@ -32,7 +31,7 @@ import org.apache.commons.lang3.StringUtils;
 import java.util.Map;
 import java.util.Set;
 
-public class StorageBackend implements ParseNode {
+public class StorageBackend {
     private String location;
     private StorageDesc storageDesc;
 
@@ -49,13 +48,6 @@ public class StorageBackend implements ParseNode {
                           StorageType storageType, Map<String, String> 
properties) {
         this.storageDesc = new StorageDesc(storageName, storageType, 
properties);
         this.location = location;
-        /*boolean convertedToS3 = BosProperties.tryConvertBosToS3(properties, 
storageType);
-        if (convertedToS3) {
-            this.storageDesc.setStorageType(StorageBackend.StorageType.S3);
-            this.location = BosProperties.convertPathToS3(location);
-        } else {
-            this.location = location;
-        }*/
     }
 
     public StorageDesc getStorageDesc() {
@@ -70,24 +62,6 @@ public class StorageBackend implements ParseNode {
         this.location = location;
     }
 
-    @Override
-    public void analyze() throws UserException {
-        StorageBackend.StorageType storageType = storageDesc.getStorageType();
-        if (storageType != StorageType.BROKER && 
StringUtils.isEmpty(storageDesc.getName())) {
-            storageDesc.setName(storageType.name());
-        }
-        if (storageType != StorageType.BROKER && storageType != StorageType.S3
-                && storageType != StorageType.HDFS) {
-            throw new NotImplementedException(storageType.toString() + " is 
not support now.");
-        }
-        FeNameFormat.checkCommonName("repository", storageDesc.getName());
-
-        if (Strings.isNullOrEmpty(location)) {
-            throw new AnalysisException("You must specify a location on the 
repository");
-        }
-        checkPath(location, storageType, null);
-    }
-
     public void validate() throws UserException {
         StorageBackend.StorageType storageType = storageDesc.getStorageType();
         if (storageType != StorageType.BROKER && 
StringUtils.isEmpty(storageDesc.getName())) {
@@ -105,20 +79,6 @@ public class StorageBackend implements ParseNode {
         checkPath(location, storageType, null);
     }
 
-    @Override
-    public String toSql() {
-        StringBuilder sb = new StringBuilder();
-        StorageBackend.StorageType storageType = storageDesc.getStorageType();
-        sb.append(storageType.name());
-        if (storageType == StorageType.BROKER) {
-            sb.append(" `").append(storageDesc.getName()).append("`");
-        }
-        sb.append(" ON LOCATION ").append(location).append(" PROPERTIES(")
-                .append(new 
DatasourcePrintableMap<>(storageDesc.getProperties(), " = ", true, false, true))
-                .append(")");
-        return sb.toString();
-    }
-
     public enum StorageType {
         BROKER("Doris Broker"),
         S3("Amazon S3 Simple Storage Service"),
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/TableSample.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/TableSample.java
index 20005ea8741..e73cbc9bfe1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/TableSample.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/TableSample.java
@@ -17,8 +17,6 @@
 
 package org.apache.doris.analysis;
 
-import org.apache.doris.common.AnalysisException;
-
 /*
  * To represent following stmt:
  *      TABLESAMPLE (10 PERCENT)
@@ -66,14 +64,7 @@ public class TableSample implements ParseNode {
     }
 
     @Override
-    public void analyze() throws AnalysisException {
-        if (sampleValue <= 0 || (isPercent && sampleValue > 100)) {
-            throw new AnalysisException("table sample value must be greater 
than 0, percent need less than 100.");
-        }
-    }
-
-    @Override
-    public String toSql() {
+    public String toString() {
         if (sampleValue == null) {
             return "";
         }
@@ -92,9 +83,4 @@ public class TableSample implements ParseNode {
         }
         return sb.toString();
     }
-
-    @Override
-    public String toString() {
-        return toSql();
-    }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java
index 98384f2dcf2..cd6690219df 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java
@@ -621,25 +621,6 @@ public class Database extends MetaObject implements 
Writable, DatabaseIf<Table>,
         return table;
     }
 
-    /**
-     * This is a thread-safe method when nameToTable is a concurrent hash map
-     */
-    @Override
-    public Table getNonTempTableNullable(String tableName) {
-        if (GlobalVariable.isStoredTableNamesLowerCase()) {
-            tableName = tableName.toLowerCase();
-        }
-        if (GlobalVariable.isTableNamesCaseInsensitive()) {
-            tableName = lowerCaseToTableName.get(tableName.toLowerCase());
-            if (tableName == null) {
-                return null;
-            }
-        }
-
-        Table table = nameToTable.get(tableName);
-        return table;
-    }
-
     /**
      * This is a thread-safe method when idToTable is a concurrent hash map
      */
@@ -648,34 +629,6 @@ public class Database extends MetaObject implements 
Writable, DatabaseIf<Table>,
         return idToTable.get(tableId);
     }
 
-    public int getMaxReplicationNum() {
-        int ret = 0;
-        readLock();
-        try {
-            for (Table table : idToTable.values()) {
-                if (!table.isManagedTable()) {
-                    continue;
-                }
-                OlapTable olapTable = (OlapTable) table;
-                table.readLock();
-                try {
-                    for (Partition partition : olapTable.getAllPartitions()) {
-                        short replicationNum = olapTable.getPartitionInfo()
-                                
.getReplicaAllocation(partition.getId()).getTotalReplicaNum();
-                        if (ret < replicationNum) {
-                            ret = replicationNum;
-                        }
-                    }
-                } finally {
-                    table.readUnlock();
-                }
-            }
-        } finally {
-            readUnlock();
-        }
-        return ret;
-    }
-
     public static Database read(DataInput in) throws IOException {
         LOG.info("read db from journal {}", in);
         Database db = GsonUtils.GSON.fromJson(Text.readString(in), 
Database.class);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java
index cc1abeb4372..ad0297a482d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java
@@ -111,8 +111,6 @@ public interface DatabaseIf<T extends TableIf> {
 
     T getTableNullable(String tableName);
 
-    T getNonTempTableNullable(String tableName);
-
     default T getTableNullableIfException(String tableName) {
         try {
             return getTableNullable(tableName);
@@ -141,15 +139,6 @@ public interface DatabaseIf<T extends TableIf> {
         return table;
     }
 
-    default <E extends Exception> T getNonTempTableOrException(String 
tableName,
-            java.util.function.Function<String, E> e) throws E {
-        T table = getNonTempTableNullable(tableName);
-        if (table == null) {
-            throw e.apply(tableName);
-        }
-        return table;
-    }
-
     default <E extends Exception> T getTableOrException(long tableId, 
Function<Long, E> e) throws E {
         T table = getTableNullable(tableId);
         if (table == null) {
@@ -163,11 +152,6 @@ public interface DatabaseIf<T extends TableIf> {
                                                         
ErrorCode.ERR_BAD_TABLE_ERROR));
     }
 
-    default T getNonTempTableOrMetaException(String tableName) throws 
MetaNotFoundException {
-        return getNonTempTableOrException(tableName, t -> new 
MetaNotFoundException("table not found, tableName=" + t,
-            ErrorCode.ERR_BAD_TABLE_ERROR));
-    }
-
     default T getTableOrMetaException(long tableId) throws 
MetaNotFoundException {
         return getTableOrException(tableId, t -> new 
MetaNotFoundException("table not found, tableId=" + t,
                                                         
ErrorCode.ERR_BAD_TABLE_ERROR));
@@ -183,17 +167,6 @@ public interface DatabaseIf<T extends TableIf> {
         return table;
     }
 
-    default T getNonTempTableOrMetaException(String tableName, 
TableIf.TableType tableType)
-            throws MetaNotFoundException {
-        T table = getNonTempTableOrMetaException(tableName);
-        TableType type = Objects.requireNonNull(table.getType(), "table type 
not found, type = " + table.getType());
-        if (type != tableType && type.getParentType() != tableType) {
-            throw new MetaNotFoundException(
-                "table type is not " + tableType + ", tableName=" + tableName 
+ ", type=" + type);
-        }
-        return table;
-    }
-
     default T getTableOrMetaException(String tableName, 
List<TableIf.TableType> tableTypes)
             throws MetaNotFoundException {
         T table = getTableOrMetaException(tableName);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIndexes.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIndexes.java
index 345362e2d53..2e5b781c21f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIndexes.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIndexes.java
@@ -44,11 +44,6 @@ public class TableIndexes {
         this.properties = Maps.newHashMap();
     }
 
-    public TableIndexes(List<Index> indexes, Map<String, String> properties) {
-        this.indexes = indexes;
-        this.properties = properties;
-    }
-
     public List<Index> getIndexes() {
         if (indexes == null) {
             indexes = Lists.newArrayList();
@@ -67,7 +62,7 @@ public class TableIndexes {
     }
 
     public List<Index> getCopiedIndexes() {
-        if (indexes == null || indexes.size() == 0) {
+        if (indexes == null || indexes.isEmpty()) {
             return Lists.newArrayList();
         } else {
             return Lists.newArrayList(indexes);
@@ -86,7 +81,7 @@ public class TableIndexes {
     }
 
     public Map<String, String> getCopiedProperties() {
-        if (properties == null || properties.size() == 0) {
+        if (properties == null || properties.isEmpty()) {
             return new HashMap<>();
         } else {
             return new HashMap<>(properties);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogIf.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogIf.java
index 51db7c9a790..c598ef520f5 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogIf.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogIf.java
@@ -90,9 +90,6 @@ public interface CatalogIf<T extends DatabaseIf> {
     Map<String, String> getProperties();
 
     default void notifyPropertiesUpdated(Map<String, String> updatedProps) {
-        if (this instanceof ExternalCatalog) {
-            ((ExternalCatalog) this).resetToUninitialized(false);
-        }
     }
 
     void modifyCatalogName(String name);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java
index 43717911ca1..c464a82f251 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalCatalog.java
@@ -1337,6 +1337,7 @@ public abstract class ExternalCatalog
     @Override
     public void notifyPropertiesUpdated(Map<String, String> updatedProps) {
         CatalogIf.super.notifyPropertiesUpdated(updatedProps);
+        resetToUninitialized(false);
         String schemaCacheTtl = 
updatedProps.getOrDefault(SCHEMA_CACHE_TTL_SECOND, null);
         if (java.util.Objects.nonNull(schemaCacheTtl)) {
             ExternalMetaCacheMgr extMetaCacheMgr = 
Env.getCurrentEnv().getExtMetaCacheMgr();
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalDatabase.java 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalDatabase.java
index 1d4c1746503..b716ce5366b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalDatabase.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalDatabase.java
@@ -523,11 +523,6 @@ public abstract class ExternalDatabase<T extends 
ExternalTable>
         return finalName;
     }
 
-    @Override
-    public T getNonTempTableNullable(String tableName) {
-        throw new NotImplementedException("getNonTempTableNullable() is not 
implemented");
-    }
-
     @Override
     public T getTableNullable(long tableId) {
         makeSureInitialized();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java 
b/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java
index da2b347d438..0b52f3a3b0d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java
@@ -247,7 +247,6 @@ public class ExportJob implements Writable {
                 for (int i = 0; i < selectStmtPerParallel.size(); ++i) {
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("ExportTaskExecutor {} is responsible for 
outfile:", i);
-                        LOG.debug("outfile sql: [{}]", 
selectStmtPerParallel.get(i).get().toSql());
                     }
                 }
             }
@@ -346,7 +345,7 @@ public class ExportJob implements Writable {
         }
 
         StatementBase statementBase = new 
LogicalPlanAdapter(outfileLogicalPlan, statementContext);
-        statementBase.setOrigStmt(new OriginStatement(statementBase.toSql(), 
0));
+        statementBase.setOrigStmt(new OriginStatement("", 0));
         return statementBase;
     }
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java
index 8b6b307634a..4229704a566 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java
@@ -374,7 +374,7 @@ public class AuditLogHelper {
             }
         } else {
             if (!ctx.getState().isQuery() && (parsedStmt != null && 
parsedStmt.needAuditEncryption())) {
-                encryptSql = parsedStmt.toSql();
+                encryptSql = "";
             }
         }
         auditEventBuilder.setStmt(handleStmt(encryptSql, parsedStmt));
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/statistics/util/StatisticsUtil.java 
b/fe/fe-core/src/main/java/org/apache/doris/statistics/util/StatisticsUtil.java
index dac74333170..e71bf8af63b 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/statistics/util/StatisticsUtil.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/statistics/util/StatisticsUtil.java
@@ -52,7 +52,6 @@ import org.apache.doris.common.FeConstants;
 import org.apache.doris.common.Pair;
 import org.apache.doris.common.util.TimeUtils;
 import org.apache.doris.datasource.CatalogIf;
-import org.apache.doris.datasource.ExternalTable;
 import org.apache.doris.datasource.InternalCatalog;
 import org.apache.doris.datasource.hive.HMSExternalTable;
 import org.apache.doris.datasource.hive.HMSExternalTable.DLAType;
@@ -85,7 +84,6 @@ import org.apache.doris.statistics.PartitionColumnStatistic;
 import org.apache.doris.statistics.ResultRow;
 import org.apache.doris.statistics.StatisticConstants;
 import org.apache.doris.statistics.TableStatsMeta;
-import org.apache.doris.system.Frontend;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Maps;
@@ -101,34 +99,24 @@ import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
 import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.charset.StandardCharsets;
 import java.text.SimpleDateFormat;
 import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeParseException;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Base64;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 import java.util.Optional;
-import java.util.Set;
-import java.util.StringJoiner;
 import java.util.concurrent.ConcurrentMap;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 
 public class StatisticsUtil {
     private static final Logger LOG = 
LogManager.getLogger(StatisticsUtil.class);
 
-    private static final String ID_DELIMITER = "-";
-
     private static final String TOTAL_SIZE = "totalSize";
     private static final String NUM_ROWS = "numRows";
     private static final String SPARK_NUM_ROWS = 
"spark.sql.statistics.numRows";
@@ -414,13 +402,6 @@ public class StatisticsUtil {
         return tblIf.getColumn(columnName);
     }
 
-    @SuppressWarnings({"unchecked"})
-    public static Column findColumn(String catalogName, String dbName, String 
tblName, String columnName)
-            throws Throwable {
-        TableIf tableIf = findTable(catalogName, dbName, tblName);
-        return tableIf.getColumn(columnName);
-    }
-
     /**
      * Throw RuntimeException if table not exists.
      */
@@ -449,13 +430,13 @@ public class StatisticsUtil {
      * Throw RuntimeException if database not exists.
      */
     @SuppressWarnings({"unchecked", "rawtypes"})
-    public static DatabaseIf findDatabase(String catalogName, String dbName) 
throws Throwable {
+    private static DatabaseIf findDatabase(String catalogName, String dbName) 
throws Throwable {
         CatalogIf catalog = findCatalog(catalogName);
         return catalog.getDbOrException(dbName,
                 d -> new RuntimeException("DB: " + d + " not exists"));
     }
 
-    public static DatabaseIf<? extends TableIf> findDatabase(long catalogId, 
long dbId)  {
+    private static DatabaseIf<? extends TableIf> findDatabase(long catalogId, 
long dbId)  {
         CatalogIf<? extends DatabaseIf<? extends TableIf>> catalog = 
findCatalog(catalogId);
         return catalog.getDbOrException(dbId,
                 d -> new RuntimeException("DB: " + d + " not exists"));
@@ -475,14 +456,6 @@ public class StatisticsUtil {
                 c -> new RuntimeException("Catalog: " + c + " not exists"));
     }
 
-    public static boolean isNullOrEmpty(String str) {
-        return Optional.ofNullable(str)
-                .map(String::trim)
-                .map(String::toLowerCase)
-                .map(s -> "null".equalsIgnoreCase(s) || s.isEmpty())
-                .orElse(true);
-    }
-
     public static boolean statsTblAvailable() {
         if (!InternalSchemaInitializer.isStatsTableSchemaValid()) {
             return false;
@@ -540,48 +513,6 @@ public class StatisticsUtil {
         return true;
     }
 
-    public static Map<Long, Partition> getIdToPartition(TableIf table) {
-        return table.getPartitionNames().stream()
-                .map(table::getPartition)
-                .filter(Objects::nonNull)
-                .collect(Collectors.toMap(
-                        Partition::getId,
-                        Function.identity()
-                ));
-    }
-
-    public static Map<Long, String> getPartitionIdToName(TableIf table) {
-        return table.getPartitionNames().stream()
-                .map(table::getPartition)
-                .collect(Collectors.toMap(
-                        Partition::getId,
-                        Partition::getName
-                ));
-    }
-
-    public static Set<String> getPartitionIds(TableIf table) {
-        if (table instanceof OlapTable) {
-            return ((OlapTable) 
table).getPartitionIds().stream().map(String::valueOf).collect(Collectors.toSet());
-        } else if (table instanceof ExternalTable) {
-            return table.getPartitionNames();
-        }
-        throw new RuntimeException(String.format("Not supported Table %s", 
table.getClass().getName()));
-    }
-
-    public static <T> String joinElementsToString(Collection<T> values, String 
delimiter) {
-        StringJoiner builder = new StringJoiner(delimiter);
-        values.forEach(v -> builder.add(String.valueOf(v)));
-        return builder.toString();
-    }
-
-    public static int convertStrToInt(String str) {
-        return StringUtils.isNumeric(str) ? Integer.parseInt(str) : 0;
-    }
-
-    public static long convertStrToLong(String str) {
-        return StringUtils.isNumeric(str) ? Long.parseLong(str) : 0;
-    }
-
     public static String getReadableTime(long timeInMs) {
         if (timeInMs <= 0) {
             return "";
@@ -590,45 +521,6 @@ public class StatisticsUtil {
         return format.format(new Date(timeInMs));
     }
 
-    @SafeVarargs
-    public static <T> String constructId(T... items) {
-        if (items == null || items.length == 0) {
-            return "";
-        }
-        List<String> idElements = Arrays.stream(items)
-                .map(String::valueOf)
-                .collect(Collectors.toList());
-        return StatisticsUtil.joinElementsToString(idElements, ID_DELIMITER);
-    }
-
-    public static String replaceParams(String template, Map<String, String> 
params) {
-        StringSubstitutor stringSubstitutor = new StringSubstitutor(params);
-        return stringSubstitutor.replace(template);
-    }
-
-
-    /**
-     * The health of the table indicates the health of the table statistics.
-     * When update_rows >= row_count, the health is 0;
-     * when update_rows < row_count, the health degree is 100 (1 - update_rows 
row_count).
-     *
-     * @param updatedRows The number of rows updated by the table
-     * @param totalRows The current number of rows in the table
-     * @return Health, the value range is [0, 100], the larger the value, the 
healthier the statistics of the table.
-     */
-    public static int getTableHealth(long totalRows, long updatedRows) {
-        // Avoid analyze empty table every time.
-        if (totalRows == 0 && updatedRows == 0) {
-            return 100;
-        }
-        if (updatedRows >= totalRows) {
-            return 0;
-        } else {
-            double healthCoefficient = (double) (totalRows - updatedRows) / 
(double) totalRows;
-            return (int) (healthCoefficient * 100.0);
-        }
-    }
-
     /**
      * Estimate hive table row count.
      * First get it from remote table parameters. If not found, estimate it : 
totalSize/estimatedRowSize
@@ -667,7 +559,7 @@ public class StatisticsUtil {
         return rows;
     }
 
-    public static long getRowCountFromParameters(Map<String, String> 
parameters) {
+    private static long getRowCountFromParameters(Map<String, String> 
parameters) {
         if (parameters == null) {
             return TableIf.UNKNOWN_ROW_COUNT;
         }
@@ -777,23 +669,10 @@ public class StatisticsUtil {
         return !KeysType.UNIQUE_KEYS.equals(keysType) || 
olapTable.isUniqKeyMergeOnWrite() || c.isKey();
     }
 
-    public static void sleep(long millis) {
-        try {
-            Thread.sleep(millis);
-        } catch (InterruptedException ignore) {
-            // IGNORE
-        }
-    }
-
     public static String quote(String str) {
         return "'" + str + "'";
     }
 
-    public static boolean isMaster(Frontend frontend) {
-        InetSocketAddress socketAddress = new 
InetSocketAddress(frontend.getHost(), frontend.getEditLogPort());
-        return 
Env.getCurrentEnv().getHaProtocol().getLeader().equals(socketAddress);
-    }
-
     public static String escapeSQL(String str) {
         if (str == null) {
             return null;
@@ -809,28 +688,6 @@ public class StatisticsUtil {
         return str.replace("`", "``");
     }
 
-    public static boolean isExternalTable(String catalogName, String dbName, 
String tblName) {
-        TableIf table;
-        try {
-            table = StatisticsUtil.findTable(catalogName, dbName, tblName);
-        } catch (Throwable e) {
-            LOG.warn(e.getMessage());
-            return false;
-        }
-        return table instanceof ExternalTable;
-    }
-
-    public static boolean isExternalTable(long catalogId, long dbId, long 
tblId) {
-        TableIf table;
-        try {
-            table = findTable(catalogId, dbId, tblId);
-        } catch (Throwable e) {
-            LOG.warn(e.getMessage());
-            return false;
-        }
-        return table instanceof ExternalTable;
-    }
-
     public static boolean inAnalyzeTime(LocalTime now) {
         try {
             Pair<LocalTime, LocalTime> range = 
findConfigFromGlobalSessionVar();
@@ -950,16 +807,6 @@ public class StatisticsUtil {
         return GlobalVariable.partitionAnalyzeBatchSize;
     }
 
-    public static long getHugeTableAutoAnalyzeIntervalInMillis() {
-        try {
-            return 
findConfigFromGlobalSessionVar(SessionVariable.HUGE_TABLE_AUTO_ANALYZE_INTERVAL_IN_MILLIS)
-                    .hugeTableAutoAnalyzeIntervalInMillis;
-        } catch (Exception e) {
-            LOG.warn("Failed to get value of 
huge_table_auto_analyze_interval_in_millis, return default", e);
-        }
-        return StatisticConstants.HUGE_TABLE_AUTO_ANALYZE_INTERVAL_IN_MILLIS;
-    }
-
     public static long getExternalTableAutoAnalyzeIntervalInMillis() {
         try {
             return 
findConfigFromGlobalSessionVar(SessionVariable.EXTERNAL_TABLE_AUTO_ANALYZE_INTERVAL_IN_MILLIS)
@@ -1018,21 +865,6 @@ public class StatisticsUtil {
         return StatisticConstants.PARTITION_SAMPLE_ROW_COUNT;
     }
 
-    public static String encodeValue(ResultRow row, int index) {
-        if (row == null || row.getValues().size() <= index) {
-            return "NULL";
-        }
-        return encodeString(row.get(index));
-    }
-
-    public static String encodeString(String value) {
-        if (value == null) {
-            return "NULL";
-        } else {
-            return 
Base64.getEncoder().encodeToString(value.getBytes(StandardCharsets.UTF_8));
-        }
-    }
-
     /**
      * Check if the given column name is a materialized view column.
      * @param table
@@ -1178,7 +1010,7 @@ public class StatisticsUtil {
         return false;
     }
 
-    public static boolean needAnalyzePartition(OlapTable table, TableStatsMeta 
tableStatsStatus,
+    private static boolean needAnalyzePartition(OlapTable table, 
TableStatsMeta tableStatsStatus,
                                                ColStatsMeta columnStatsMeta) {
         if (!StatisticsUtil.enablePartitionAnalyze() || 
!table.isPartitionedTable()) {
             return false;
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/load/routineload/RoutineLoadManagerTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/load/routineload/RoutineLoadManagerTest.java
index e86d10d0c8c..e9a55b1e456 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/load/routineload/RoutineLoadManagerTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/load/routineload/RoutineLoadManagerTest.java
@@ -17,8 +17,6 @@
 
 package org.apache.doris.load.routineload;
 
-import org.apache.doris.analysis.ParseNode;
-import org.apache.doris.analysis.Separator;
 import org.apache.doris.analysis.UserIdentity;
 import org.apache.doris.catalog.Database;
 import org.apache.doris.catalog.Env;
@@ -64,7 +62,6 @@ import org.junit.Assert;
 import org.junit.Test;
 
 import java.lang.reflect.Field;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -86,9 +83,6 @@ public class RoutineLoadManagerTest {
         String dbName = "db1";
         LabelNameInfo labelNameInfo = new LabelNameInfo(dbName, jobName);
         String tableNameString = "table1";
-        List<ParseNode> loadPropertyList = new ArrayList<>();
-        Separator columnSeparator = new Separator(",");
-        loadPropertyList.add(columnSeparator);
         Map<String, String> properties = Maps.newHashMap();
         
properties.put(CreateRoutineLoadInfo.DESIRED_CONCURRENT_NUMBER_PROPERTY, "2");
         String typeName = LoadDataSourceType.KAFKA.name();
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/statistics/util/StatisticsUtilTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/statistics/util/StatisticsUtilTest.java
index 11e71d7c4b8..4b1e6331c82 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/statistics/util/StatisticsUtilTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/statistics/util/StatisticsUtilTest.java
@@ -49,11 +49,9 @@ import org.apache.doris.qe.SessionVariable;
 import org.apache.doris.rpc.RpcException;
 import org.apache.doris.statistics.AnalysisManager;
 import org.apache.doris.statistics.ColStatsMeta;
-import org.apache.doris.statistics.ResultRow;
 import org.apache.doris.statistics.TableStatsMeta;
 import org.apache.doris.thrift.TStorageType;
 
-import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import mockit.Mock;
 import mockit.MockUp;
@@ -62,11 +60,9 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 
-import java.nio.charset.StandardCharsets;
 import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
-import java.util.Base64;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -154,32 +150,6 @@ class StatisticsUtilTest {
         
Assertions.assertFalse(StatisticsUtil.inAnalyzeTime(LocalTime.parse(now, 
timeFormatter)));
     }
 
-
-    @Test
-    void testEncodeValue() throws Exception {
-        Assertions.assertEquals("NULL", StatisticsUtil.encodeValue(null, 0));
-
-        ResultRow row = new ResultRow(null);
-        Assertions.assertEquals("NULL", StatisticsUtil.encodeValue(row, 0));
-
-        ArrayList<String> values = Lists.newArrayList();
-        values.add("a");
-        row = new ResultRow(values);
-        Assertions.assertEquals("NULL", StatisticsUtil.encodeValue(row, 1));
-
-        values = Lists.newArrayList();
-        values.add(null);
-        row = new ResultRow(values);
-        Assertions.assertEquals("NULL", StatisticsUtil.encodeValue(row, 0));
-
-        values.add("a");
-        row = new ResultRow(values);
-        Assertions.assertEquals("NULL", StatisticsUtil.encodeValue(row, 0));
-        Assertions.assertEquals(Base64.getEncoder()
-                .encodeToString("a".getBytes(StandardCharsets.UTF_8)), 
StatisticsUtil.encodeValue(row, 1));
-        Assertions.assertEquals("NULL", StatisticsUtil.encodeValue(row, 2));
-    }
-
     @Test
     void testEscape() {
         // \'"


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to