This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit b767749e500aaa0f3209fe1be0cbbce0c6abbe58 Author: starocean999 <[email protected]> AuthorDate: Wed Sep 6 16:16:16 2023 +0800 [fix](planner)fix 'char' function's toSql implementation is wrong (#23860) --- .../org/apache/doris/analysis/FunctionCallExpr.java | 20 ++++++++++++++++++++ regression-test/data/view_p0/view_p0.out | 3 +++ regression-test/suites/view_p0/view_p0.groovy | 9 ++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java index 90f01e09cc..0ffcd5ab0a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java @@ -551,6 +551,26 @@ public class FunctionCallExpr extends Expr { sb.append("DISTINCT "); } int len = children.size(); + + if (fnName.getFunction().equalsIgnoreCase("char")) { + for (int i = 1; i < len; ++i) { + sb.append(children.get(i).toSql()); + if (i < len - 1) { + sb.append(", "); + } + } + sb.append(" using "); + String encodeType = children.get(0).toSql(); + if (encodeType.charAt(0) == '\'') { + encodeType = encodeType.substring(1, encodeType.length()); + } + if (encodeType.charAt(encodeType.length() - 1) == '\'') { + encodeType = encodeType.substring(0, encodeType.length() - 1); + } + sb.append(encodeType).append(")"); + return sb.toString(); + } + // XXX_diff are used by nereids only if (fnName.getFunction().equalsIgnoreCase("years_diff") || fnName.getFunction().equalsIgnoreCase("months_diff") || fnName.getFunction().equalsIgnoreCase("days_diff") diff --git a/regression-test/data/view_p0/view_p0.out b/regression-test/data/view_p0/view_p0.out index ff952fdaa7..976d4a3cb2 100644 --- a/regression-test/data/view_p0/view_p0.out +++ b/regression-test/data/view_p0/view_p0.out @@ -15,3 +15,6 @@ -- !sql -- 960 +-- !sql2 -- + + diff --git a/regression-test/suites/view_p0/view_p0.groovy b/regression-test/suites/view_p0/view_p0.groovy index bb6a5ab5a6..cf55380a71 100644 --- a/regression-test/suites/view_p0/view_p0.groovy +++ b/regression-test/suites/view_p0/view_p0.groovy @@ -122,5 +122,12 @@ suite("view_p0") { qt_sql "select * from test_time_diff" sql "drop view if exists test_time_diff" - + + sql "drop view if exists test_vv1;" + + sql "create view test_vv1 as select char(field2) from test_array_tbl_2;" + + qt_sql2 "select * from test_vv1;" + + sql "drop view if exists test_vv1;" } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
