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

morningman 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 600ce53475 [fix](planner) ctas should not change any meta of column in 
source table (#24767)
600ce53475 is described below

commit 600ce5347551135414638c66024b3d806f8efd04
Author: morrySnow <101034200+morrys...@users.noreply.github.com>
AuthorDate: Fri Sep 22 11:49:38 2023 +0800

    [fix](planner) ctas should not change any meta of column in source table 
(#24767)
    
    if previous PR #22770. we try to fix incorrect nullable in target table.
    However we changed nullable info of column in source table unexpectly
---
 .../org/apache/doris/analysis/CreateTableAsSelectStmt.java     |  6 ++++--
 regression-test/suites/ddl_p0/test_ctas.groovy                 | 10 +++++++---
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableAsSelectStmt.java
 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableAsSelectStmt.java
index d3a0f39a8c..2cc707b73b 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableAsSelectStmt.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableAsSelectStmt.java
@@ -17,6 +17,7 @@
 
 package org.apache.doris.analysis;
 
+import org.apache.doris.catalog.Column;
 import org.apache.doris.common.ErrorCode;
 import org.apache.doris.common.ErrorReport;
 import org.apache.doris.common.UserException;
@@ -78,8 +79,9 @@ public class CreateTableAsSelectStmt extends DdlStmt {
         Preconditions.checkArgument(outputs.size() == 
queryStmt.getResultExprs().size());
         for (int i = 0; i < outputs.size(); ++i) {
             if (queryStmt.getResultExprs().get(i).getSrcSlotRef() != null) {
-                queryStmt.getResultExprs().get(i).getSrcSlotRef().getColumn()
-                        .setIsAllowNull(outputs.get(i).isNullable());
+                Column columnCopy =  new 
Column(queryStmt.getResultExprs().get(i).getSrcSlotRef().getColumn());
+                columnCopy.setIsAllowNull(outputs.get(i).isNullable());
+                
queryStmt.getResultExprs().get(i).getSrcSlotRef().getDesc().setColumn(columnCopy);
             }
         }
         ArrayList<Expr> resultExprs = getQueryStmt().getResultExprs();
diff --git a/regression-test/suites/ddl_p0/test_ctas.groovy 
b/regression-test/suites/ddl_p0/test_ctas.groovy
index b77a25829e..954be7ef59 100644
--- a/regression-test/suites/ddl_p0/test_ctas.groovy
+++ b/regression-test/suites/ddl_p0/test_ctas.groovy
@@ -228,10 +228,14 @@ suite("test_ctas") {
         sql 'insert into a values(1, \'ww\'), (2, \'zs\');'
         sql 'insert into b values(1, 22);'
 
-        sql 'create table c properties("replication_num"="1") as select a.id, 
a.name, b.age from a left join b on a.id = b.id;'
+        sql 'set enable_nereids_planner=false'
+
+        sql 'create table c properties("replication_num"="1") as select b.id, 
a.name, b.age from a left join b on a.id = b.id;'
         
-        String desc = sql 'desc c'
-        assertTrue(desc.contains('Yes'))
+        String descC = sql 'desc c'
+        assertTrue(descC.contains('Yes'))
+        String descB = sql 'desc b'
+        assertTrue(descB.contains('No'))
     } finally {
         sql 'drop table a'
         sql 'drop table b'


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

Reply via email to