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

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


The following commit(s) were added to refs/heads/branch-1.1-lts by this push:
     new ef07219fad [fix](ctas) text column type len = 1 when create table as 
select (#14275)
ef07219fad is described below

commit ef07219fad4a025b7e7671643cecc0ec5617c38a
Author: xueweizhang <zxw520bl...@163.com>
AuthorDate: Wed Nov 16 18:19:15 2022 +0800

    [fix](ctas) text column type len = 1 when create table as select (#14275)
    
    Signed-off-by: nextdreamblue <zxw520bl...@163.com>
    
    Signed-off-by: nextdreamblue <zxw520bl...@163.com>
---
 fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java | 7 ++++++-
 fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java    | 3 ++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
index 88bbf61c9e..ee61eae290 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
@@ -175,7 +175,12 @@ public class ColumnDef {
         if (typeDef.getType().isScalarType()) {
             final ScalarType targetType = (ScalarType) typeDef.getType();
             if (targetType.getPrimitiveType().isStringType() && 
!targetType.isLengthSet()) {
-                targetType.setLength(1);
+                if (targetType.getPrimitiveType() != PrimitiveType.STRING) {
+                    targetType.setLength(1);
+                } else {
+                    // alway set text length MAX_STRING_LENGTH
+                    targetType.setLength(ScalarType.MAX_STRING_LENGTH);
+                }
             }
         }
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
index 730512cfe1..dace42f938 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
@@ -3134,7 +3134,8 @@ public class Catalog {
                 Expr resultExpr = resultExprs.get(i);
                 Type resultType = resultExpr.getType();
                 if (resultType.isStringType() && resultType.getLength() < 0) {
-                    typeDef = new TypeDef(Type.STRING);
+                    // alway set text length MAX_STRING_LENGTH
+                    typeDef = new TypeDef(ScalarType.createStringType());
                 } else if (resultType.isDecimalV2() && 
resultType.equals(ScalarType.DECIMALV2)) {
                     typeDef = new TypeDef(ScalarType.createDecimalV2Type(27, 
9));
                 } else {


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

Reply via email to