[Fix](Nereids) fix create table as select of view with unknowed length character type (#25471)

Problem:
when create table as select from a view with unknown length character type, be would return an error of inserting data failed

Example:
doris/regression-test/suites/ddl_p0/test_ctas.groovy

Reason & Solved:
BE can not derive varchar length automaticly so FE should tell BE to maximize the size of varchar type
This commit is contained in:
LiBinfeng
2023-10-31 14:50:28 +08:00
committed by GitHub
parent 0449a240f4
commit ea1e8fa15d
2 changed files with 40 additions and 2 deletions

View File

@ -108,8 +108,8 @@ public class CreateTableCommand extends Command implements ForwardWithSync {
} else if (i == 0 && dataType.isStringType()) {
dataType = VarcharType.createVarcharType(ScalarType.MAX_VARCHAR_LENGTH);
} else if (dataType instanceof CharacterType) {
// if column is not come from column, we should set varchar length to max
if (((CharacterType) dataType).getLen() > 0 && !s.isColumnFromTable()) {
// if column is not come from table, we should set varchar length to max
if (!s.isColumnFromTable()) {
dataType = VarcharType.createVarcharType(ScalarType.MAX_VARCHAR_LENGTH);
}
}