Skip to content

Commit

Permalink
[fix](compability) type toSql should return lowercase string
Browse files Browse the repository at this point in the history
  • Loading branch information
morrySnow committed Jul 17, 2024
1 parent 29b99ad commit 26d006e
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java
Original file line number Diff line number Diff line change
Expand Up @@ -617,38 +617,38 @@ public String toSql(int depth) {
switch (type) {
case CHAR:
if (isWildcardChar()) {
stringBuilder.append("CHARACTER").append("(").append(MAX_CHAR_LENGTH).append(")");
stringBuilder.append("character").append("(").append(MAX_CHAR_LENGTH).append(")");
} else if (Strings.isNullOrEmpty(lenStr)) {
stringBuilder.append("CHAR").append("(").append(len).append(")");
stringBuilder.append("char").append("(").append(len).append(")");
} else {
stringBuilder.append("CHAR").append("(`").append(lenStr).append("`)");
stringBuilder.append("char").append("(`").append(lenStr).append("`)");
}
break;
case VARCHAR:
if (isWildcardVarchar()) {
return "VARCHAR(" + MAX_VARCHAR_LENGTH + ")";
return "varcahr(" + MAX_VARCHAR_LENGTH + ")";
} else if (Strings.isNullOrEmpty(lenStr)) {
stringBuilder.append("VARCHAR").append("(").append(len).append(")");
stringBuilder.append("varchar").append("(").append(len).append(")");
} else {
stringBuilder.append("VARCHAR").append("(`").append(lenStr).append("`)");
stringBuilder.append("varchar").append("(`").append(lenStr).append("`)");
}
break;
case DECIMALV2:
if (Strings.isNullOrEmpty(precisionStr)) {
stringBuilder.append("DECIMALV2").append("(").append(precision)
stringBuilder.append("decimal").append("(").append(precision)
.append(", ").append(scale).append(")");
} else if (!Strings.isNullOrEmpty(precisionStr) && !Strings.isNullOrEmpty(scaleStr)) {
stringBuilder.append("DECIMALV2").append("(`").append(precisionStr)
stringBuilder.append("decimal").append("(`").append(precisionStr)
.append("`, `").append(scaleStr).append("`)");
} else {
stringBuilder.append("DECIMALV2").append("(`").append(precisionStr).append("`)");
stringBuilder.append("decimal").append("(`").append(precisionStr).append("`)");
}
break;
case DECIMAL32:
case DECIMAL64:
case DECIMAL128:
case DECIMAL256:
String typeName = "DECIMALV3";
String typeName = "decimal";
if (Strings.isNullOrEmpty(precisionStr)) {
stringBuilder.append(typeName).append("(").append(precision)
.append(", ").append(scale).append(")");
Expand All @@ -660,30 +660,30 @@ public String toSql(int depth) {
}
break;
case DATETIMEV2:
stringBuilder.append("DATETIMEV2").append("(").append(scale).append(")");
stringBuilder.append("datetime").append("(").append(scale).append(")");
break;
case TIME:
stringBuilder.append("TIME");
stringBuilder.append("time");
break;
case TIMEV2:
stringBuilder.append("TIME").append("(").append(scale).append(")");
stringBuilder.append("time").append("(").append(scale).append(")");
break;
case BOOLEAN:
return "BOOLEAN";
return "boolean";
case TINYINT:
return "TINYINT";
return "tinyint";
case SMALLINT:
return "SMALLINT";
return "smallint";
case INT:
return "INT";
return "int";
case BIGINT:
return "BIGINT";
return "bigint";
case LARGEINT:
return "LARGEINT";
return "largeint";
case IPV4:
return "IPV4";
return "ipv4";
case IPV6:
return "IPV6";
return "ipv6";
case FLOAT:
case DOUBLE:
case DATE:
Expand All @@ -696,13 +696,13 @@ public String toSql(int depth) {
case LAMBDA_FUNCTION:
case ARRAY:
case NULL_TYPE:
stringBuilder.append(type);
stringBuilder.append(type.toString().toLowerCase());
break;
case STRING:
stringBuilder.append("TEXT");
stringBuilder.append("text");
break;
case JSONB:
stringBuilder.append("JSON");
stringBuilder.append("json");
break;
default:
stringBuilder.append("unknown type: ").append(type);
Expand Down

0 comments on commit 26d006e

Please sign in to comment.