[Fix] Only datetime and datetimev2 types can use current_timestamp as column default value (#31395)
for this kind of sql:
create table test_default10(
a int,
b varchar(100) default current_timestamp
)
distributed by hash(a)
properties('replication_num'="1");
add check:
Types other than DATETIME and DATETIMEV2 cannot use current_timestamp as the default value
This commit is contained in:
@ -542,6 +542,16 @@ public class ColumnDef {
|
||||
default:
|
||||
throw new AnalysisException("Unsupported type: " + type);
|
||||
}
|
||||
if (null != defaultValueExprDef && defaultValueExprDef.getExprName().equals("now")) {
|
||||
switch (primitiveType) {
|
||||
case DATETIME:
|
||||
case DATETIMEV2:
|
||||
break;
|
||||
default:
|
||||
throw new AnalysisException("Types other than DATETIME and DATETIMEV2 "
|
||||
+ "cannot use current_timestamp as the default value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String toSql() {
|
||||
|
||||
Reference in New Issue
Block a user