[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.
This commit is contained in:
mch_ucchi
2023-02-16 20:01:13 +08:00
committed by GitHub
parent f86e8ec395
commit 407ccaaff7
2 changed files with 11 additions and 0 deletions

View File

@ -1239,6 +1239,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());
}

View File

@ -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"""
}
}