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

yiguolei pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new e8bb279b5ad [fix](char) fix char column type not check lenght (#30266) 
(#30675)
e8bb279b5ad is described below

commit e8bb279b5ad4e8ca6d5554434acba11c56cf1ba1
Author: xueweizhang <[email protected]>
AuthorDate: Sun Feb 4 14:26:14 2024 +0800

    [fix](char) fix char column type not check lenght (#30266) (#30675)
---
 .../java/org/apache/doris/analysis/TypeDef.java    |  1 -
 .../datatype_p0/string/test_string_basic.groovy    | 29 ++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/TypeDef.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/TypeDef.java
index df00ef62b57..bde4c653c23 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/TypeDef.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/TypeDef.java
@@ -149,7 +149,6 @@ public class TypeDef implements ParseNode {
                 } else {
                     name = "CHAR";
                     maxLen = ScalarType.MAX_CHAR_LENGTH;
-                    return;
                 }
                 int len = scalarType.getLength();
                 // len is decided by child, when it is -1.
diff --git a/regression-test/suites/datatype_p0/string/test_string_basic.groovy 
b/regression-test/suites/datatype_p0/string/test_string_basic.groovy
index d5884c29058..6a25e78a80e 100644
--- a/regression-test/suites/datatype_p0/string/test_string_basic.groovy
+++ b/regression-test/suites/datatype_p0/string/test_string_basic.groovy
@@ -45,5 +45,34 @@ suite("test_string_basic") {
          (2, repeat("test1111", 131072))
         """
     order_qt_select_str_tb "select k1, md5(v1), length(v1) from ${tbName}"
+
+    def table_too_long = "fail"
+    sql "drop table if exists char_table_too_long;"
+    try {
+        sql """
+        CREATE TABLE IF NOT EXISTS char_table_too_long (k1 VARCHAR(10) NULL, 
v1 CHAR(300) NULL) 
+        UNIQUE KEY(k1) DISTRIBUTED BY HASH(k1) BUCKETS 5 
properties("replication_num" = "1")
+        """
+        table_too_long = "success"
+    } catch(Exception e) {
+        logger.info(e.getMessage())
+        assertTrue(e.getMessage().contains("size must be <= 255"))
+    }
+    assertEquals(table_too_long, "fail")
+    sql "drop table if exists char_table_too_long;"
+
+    sql "drop table if exists varchar_table_too_long;"
+    try {
+        sql """
+        CREATE TABLE IF NOT EXISTS varchar_table_too_long (k1 VARCHAR(10) 
NULL, v1 VARCHAR(65599) NULL) 
+        UNIQUE KEY(k1) DISTRIBUTED BY HASH(k1) BUCKETS 5 
properties("replication_num" = "1")
+        """
+        table_too_long = "success"
+    } catch(Exception e) {
+        logger.info(e.getMessage())
+        assertTrue(e.getMessage().contains("size must be <= 65533"))
+    }
+    assertEquals(table_too_long, "fail")
+    sql "drop table if exists varchar_table_too_long;"
 }
 


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

Reply via email to