This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 9642923b6e9f04b3a942f587782ef7827195123a Author: Petrichor <[email protected]> AuthorDate: Sat Oct 7 01:43:03 2023 -0500 [fix](jdbc catalog )fix jdbc catalog current_timestamp default (#25016) This problem is caused when you read table data from Mariadb where the datatime type default value is set to current_timestamp(). --- .../doris/datasource/jdbc/client/JdbcMySQLClient.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java index da178b6f81a..cb06722a05d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java @@ -176,12 +176,17 @@ public class JdbcMySQLClient extends JdbcClient { List<Column> dorisTableSchema = Lists.newArrayListWithCapacity(jdbcTableSchema.size()); for (JdbcFieldSchema field : jdbcTableSchema) { 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; - defaultValueExprDef = new DefaultValueExprDef("now", precision); + if (field.getDefaultValue() != null) { + String colDefaultValue = field.getDefaultValue().toLowerCase(); + // current_timestamp() + if (colDefaultValue.startsWith("current_timestamp")) { + 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); + } } dorisTableSchema.add(new Column(field.getColumnName(), jdbcTypeToDoris(field), field.isKey(), null, --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
