[bugfix](clickhouse) fix datetime convert error. (#26128)
This commit is contained in:
@ -58,25 +58,26 @@ public class JdbcClickHouseClient extends JdbcClient {
|
||||
return createDecimalOrStringType(precision, scale);
|
||||
}
|
||||
|
||||
if ("String".contains(ckType) || ckType.startsWith("Enum")
|
||||
|| ckType.startsWith("IPv") || "UUID".contains(ckType)
|
||||
if ("String".contains(ckType)
|
||||
|| ckType.startsWith("Enum")
|
||||
|| ckType.startsWith("IPv")
|
||||
|| "UUID".contains(ckType)
|
||||
|| ckType.startsWith("FixedString")) {
|
||||
return ScalarType.createStringType();
|
||||
}
|
||||
|
||||
if (ckType.startsWith("DateTime")) {
|
||||
// DateTime with second precision
|
||||
if (ckType.equals("DateTime")) {
|
||||
if (ckType.startsWith("DateTime(") || ckType.equals("DateTime")) {
|
||||
return ScalarType.createDatetimeV2Type(0);
|
||||
} else {
|
||||
// DateTime64 with [0~9] precision
|
||||
int indexStart = ckType.indexOf('(');
|
||||
int indexEnd = ckType.indexOf(')');
|
||||
if (indexStart != -1 && indexEnd != -1) {
|
||||
String scaleStr = ckType.substring(indexStart + 1, indexEnd);
|
||||
int scale = Integer.parseInt(scaleStr);
|
||||
if (scale > 6) {
|
||||
scale = 6;
|
||||
if (scale > JDBC_DATETIME_SCALE) {
|
||||
scale = JDBC_DATETIME_SCALE;
|
||||
}
|
||||
// return with the actual scale
|
||||
return ScalarType.createDatetimeV2Type(scale);
|
||||
|
||||
Reference in New Issue
Block a user