Skip to content

Commit

Permalink
[Fix] Only datetime and datetimev2 types can use current_timestamp as…
Browse files Browse the repository at this point in the history
… column default value
  • Loading branch information
feiniaofeiafei committed Feb 26, 2024
1 parent 205bcec commit c9be595
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,16 @@ public static void validateDefaultValue(Type type, String defaultValue, DefaultV
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() {
Expand Down

0 comments on commit c9be595

Please sign in to comment.