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
commit a60d0b21fc48439bea308408c07bec84ae962c09 Author: mch_ucchi <[email protected]> AuthorDate: Thu Feb 16 20:01:13 2023 +0800 [FIx](planner) create table as select with null_type select item cause be core bug (#16778) sql: create table t as select null as k will cause be core sometime. now we change it null_type to tinyint nullable to avoid it. --- .../src/main/java/org/apache/doris/datasource/InternalCatalog.java | 4 ++++ regression-test/suites/ddl_p0/test_ctas.groovy | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java index c50844719a..7bd96078b2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java @@ -1224,6 +1224,10 @@ public class InternalCatalog implements CatalogIf<Database> { } else if (resultType.isDecimalV3()) { typeDef = new TypeDef(ScalarType.createDecimalV3Type(resultType.getPrecision(), ((ScalarType) resultType).getScalarScale())); + } else if (resultType.isNull()) { + // if typeDef is NULL_TYPE, be will core when executing CTAS expression, + // we change it to tinyint nullable. + typeDef = TypeDef.create(PrimitiveType.TINYINT); } else { typeDef = new TypeDef(resultExpr.getType()); } diff --git a/regression-test/suites/ddl_p0/test_ctas.groovy b/regression-test/suites/ddl_p0/test_ctas.groovy index bdfb6d82b9..744aa7232b 100644 --- a/regression-test/suites/ddl_p0/test_ctas.groovy +++ b/regression-test/suites/ddl_p0/test_ctas.groovy @@ -90,6 +90,11 @@ suite("test_ctas") { qt_select """select * from test_ctas_json_object1 order by c1;""" + sql """create table a properties("replication_num"="1") as select null as c;""" + test { + sql "select * from a" + result([[null]]) + } } finally { sql """ DROP TABLE IF EXISTS test_ctas """ @@ -101,6 +106,8 @@ suite("test_ctas") { sql """ DROP TABLE IF EXISTS test_ctas_json_object """ sql """ DROP TABLE IF EXISTS test_ctas_json_object1 """ + + sql """drop table if exists a""" } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
