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

yiguolei 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 1b6e872a8a [improvement](common) table name length exceeds limit error 
message (#14368)
1b6e872a8a is described below

commit 1b6e872a8a8ada781cdaa734b29e6507d552652d
Author: gnehil <adamlee...@gmail.com>
AuthorDate: Sat Nov 19 11:36:08 2022 +0800

    [improvement](common) table name length exceeds limit error message (#14368)
    
    For the table name check, the regular match error and the length exceeds 
the limit, both of which display the message "Incorrect table name 'xxx'. Table 
name regex is 'xxx'".
    Obviously, the message cannot clearly point out what kind of error it is.
    So it is a better way to separate the two error messages.
---
 fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java    | 4 +++-
 fe/fe-core/src/main/java/org/apache/doris/common/FeNameFormat.java | 7 +++++--
 .../src/test/java/org/apache/doris/common/FeNameFormatTest.java    | 3 +++
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java 
b/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java
index 8accc585ab..4f21d77a0c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java
@@ -1695,7 +1695,9 @@ public enum ErrorCode {
     ERR_CATALOG_ACCESS_DENIED(5087, new byte[]{'4', '2', '0', '0', '0'},
             "Access denied for user '%s' to catalog '%s'"),
     ERR_NONSUPPORT_HMS_TABLE(5088, new byte[]{'4', '2', '0', '0', '0'},
-            "Nonsupport hive metastore table named '%s' in database '%s' with 
catalog '%s'.");
+            "Nonsupport hive metastore table named '%s' in database '%s' with 
catalog '%s'."),
+    ERR_TABLE_NAME_LENGTH_LIMIT(5089, new byte[]{'4', '2', '0', '0', '0'}, 
"Table name length exceeds limit, "
+     + "the length of table name '%s' is %d which is greater than the 
configuration 'table_name_length_limit' (%d).");
 
     // This is error code
     private final int code;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/FeNameFormat.java 
b/fe/fe-core/src/main/java/org/apache/doris/common/FeNameFormat.java
index 240a75c39e..465b2cd88b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/FeNameFormat.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/FeNameFormat.java
@@ -46,11 +46,14 @@ public class FeNameFormat {
 
     public static void checkTableName(String tableName) throws 
AnalysisException {
         if (Strings.isNullOrEmpty(tableName)
-                || !tableName.matches(COMMON_TABLE_NAME_REGEX)
-                || tableName.length() > Config.table_name_length_limit) {
+                || !tableName.matches(COMMON_TABLE_NAME_REGEX)) {
             
ErrorReport.reportAnalysisException(ErrorCode.ERR_WRONG_TABLE_NAME, tableName,
                     COMMON_TABLE_NAME_REGEX);
         }
+        if (tableName.length() > Config.table_name_length_limit) {
+            
ErrorReport.reportAnalysisException(ErrorCode.ERR_TABLE_NAME_LENGTH_LIMIT, 
tableName,
+                    tableName.length(), Config.table_name_length_limit);
+        }
     }
 
     public static void checkPartitionName(String partitionName) throws 
AnalysisException {
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/common/FeNameFormatTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/common/FeNameFormatTest.java
index 32678db556..eeca51fbf4 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/common/FeNameFormatTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/common/FeNameFormatTest.java
@@ -35,6 +35,9 @@ public class FeNameFormatTest {
         // length 64
         String tblName = 
"test_sys_partition_list_basic_test_list_partition_bigint_tb_uniq";
         ExceptionChecker.expectThrowsNoException(() -> 
FeNameFormat.checkTableName(tblName));
+        // length 70
+        String largeTblName = 
"test_sys_partition_list_basic_test_list_partition_bigint_tb_uniq_large";
+        ExceptionChecker.expectThrows(AnalysisException.class, () -> 
FeNameFormat.checkTableName(largeTblName));
     }
 
 }


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

Reply via email to