zy-kkk commented on code in PR #25016: URL: https://github.com/apache/doris/pull/25016#discussion_r1344084268
########## fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java: ########## @@ -178,9 +178,13 @@ public List<Column> getColumnsFromJdbc(String dbName, String tableName) { DefaultValueExprDef defaultValueExprDef = null; if (field.getDefaultValue() != null && field.getDefaultValue().toLowerCase().startsWith("current_timestamp")) { - long precision = field.getDefaultValue().toLowerCase().contains("(") - ? Long.parseLong(field.getDefaultValue().toLowerCase() - .split("\\(")[1].split("\\)")[0]) : 0; + // current_timestamp() + String colDefaultValue = field.getDefaultValue().toLowerCase(); + long precision = 0; + if (colDefaultValue.contains("(")) { + String substring = colDefaultValue.substring(18, colDefaultValue.length() - 1).trim(); + precision = substring.isEmpty() ? 0 : Long.parseLong(substring); + } defaultValueExprDef = new DefaultValueExprDef("now", precision); } Review Comment: I think the following is a better version ```Java if (field.getDefaultValue() != null) { String colDefaultValue = field.getDefaultValue().toLowerCase(); if (colDefaultValue.startsWith("current_timestamp")) { long precision = 0; if (colDefaultValue.contains("(")) { String substring = colDefaultValue.substring("current_timestamp(".length(), colDefaultValue.length() - 1).trim(); precision = substring.isEmpty() ? 0 : Long.parseLong(substring); } defaultValueExprDef = new DefaultValueExprDef("now", precision); } } ``` -- 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