Skip to content

Commit

Permalink
[bugfix](clickhouse) fix datetime convert error. (apache#26128)
Browse files Browse the repository at this point in the history
  • Loading branch information
liugddx authored Nov 7, 2023
1 parent 3ad8e27 commit b078865
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,26 @@ protected Type jdbcTypeToDoris(JdbcFieldSchema fieldSchema) {
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);
Expand Down

0 comments on commit b078865

Please sign in to comment.