morrySnow commented on code in PR #35760:
URL: https://github.com/apache/doris/pull/35760#discussion_r1624072727


##########
fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java:
##########
@@ -480,8 +480,30 @@ public static void validateDefaultValue(Type type, String 
defaultValue, DefaultV
         ScalarType scalarType = (ScalarType) type;
 
         // check if default value is valid.
-        // if not, some literal constructor will throw AnalysisException
+        // first, check if the type of defaultValue matches primitiveType.
+        // if not check it first, some literal constructor will throw 
AnalysisException,
+        // and it is not intuitive to users.
         PrimitiveType primitiveType = scalarType.getPrimitiveType();
+        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");
+            }
+        } else if (null != defaultValueExprDef
+                && 
defaultValueExprDef.getExprName().equals(DefaultValue.CURRENT_DATE.toLowerCase()))
 {

Review Comment:
   ```suggestion
                   && 
defaultValueExprDef.getExprName().equalsIgnoreCase(DefaultValue.CURRENT_DATE)) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to