[Fix](catalog) Doris datetime type conversion failed (#23906)

1. The catalog is connected to an old version of Doris, and an error is reported when using the datetime field type on the Doris surface .
2. error message [fe]:
  Caused by: java.lang.NumberFormatException: For input string: "DATETIM"
  at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:1.8.0_291]
  at java.lang.Integer.parseInt(Integer.java:580) ~[?:1.8.0_291]
  at java.lang.Integer.parseInt(Integer.java:615) ~[?:1.8.0_291]
  at org.apache.doris.datasource.jdbc.client.JdbcMySQLClient.dorisTypeToDoris(JdbcMySQLClient.java:401) ~[doris-fe.jar:1.2- 
 SNAPSHOT]
This commit is contained in:
ChinaYiGuan
2023-09-08 10:49:35 +08:00
committed by GitHub
parent cb29d1a395
commit c68e6a9ca8

View File

@ -400,7 +400,8 @@ public class JdbcMySQLClient extends JdbcClient {
return ScalarType.createDateV2Type();
case "DATETIME":
case "DATETIMEV2": {
int scale = Integer.parseInt(upperType.substring(openParen + 1, upperType.length() - 1));
int scale = (openParen == -1) ? 6
: Integer.parseInt(upperType.substring(openParen + 1, upperType.length() - 1));
if (scale > 6) {
scale = 6;
}