This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 64f7feced92 [Fix](planner) fix bug of char(255) toSql (#37340) (#37673)
64f7feced92 is described below
commit 64f7feced92ed7ae64563f63470a1e58bfcc3ec1
Author: feiniaofeiafei <[email protected]>
AuthorDate: Fri Jul 12 10:32:15 2024 +0800
[Fix](planner) fix bug of char(255) toSql (#37340) (#37673)
cherry-pick #37340 from master
---
fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java | 4 ++--
.../src/test/java/org/apache/doris/catalog/CreateFunctionTest.java | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git
a/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java
b/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java
index b4a81068b3f..6f684471e56 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java
@@ -578,7 +578,7 @@ public class ScalarType extends Type {
public String toString() {
if (type == PrimitiveType.CHAR) {
if (isWildcardChar()) {
- return "CHARACTER";
+ return "CHARACTER(" + MAX_CHAR_LENGTH + ")";
}
return "CHAR(" + len + ")";
} else if (type == PrimitiveType.DECIMALV2) {
@@ -614,7 +614,7 @@ public class ScalarType extends Type {
switch (type) {
case CHAR:
if (isWildcardChar()) {
- stringBuilder.append("CHARACTER");
+
stringBuilder.append("CHARACTER").append("(").append(MAX_CHAR_LENGTH).append(")");
} else if (Strings.isNullOrEmpty(lenStr)) {
stringBuilder.append("CHAR").append("(").append(len).append(")");
} else {
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateFunctionTest.java
b/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateFunctionTest.java
index 7c9a45febae..76f54eea9f6 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateFunctionTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateFunctionTest.java
@@ -285,7 +285,7 @@ public class CreateFunctionTest {
testFunctionQuery(ctx, queryStr, true);
queryStr = "select to_char(k1, 4) from db2.tbl1;";
-
Assert.assertTrue(dorisAssert.query(queryStr).explainQuery().contains("CAST(`k1`
AS CHARACTER)"));
+
Assert.assertTrue(dorisAssert.query(queryStr).explainQuery().contains("CAST(`k1`
AS CHARACTER(255))"));
}
private void testFunctionQuery(ConnectContext ctx, String queryStr,
Boolean isStringLiteral) throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]