Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](planner)fix 'char' function's toSql implementation is wrong #23860

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,26 @@ private String paramsToSql() {
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")
Expand Down
3 changes: 3 additions & 0 deletions regression-test/data/view_p0/view_p0.out
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
-- !sql --
960

-- !sql2 --


9 changes: 8 additions & 1 deletion regression-test/suites/view_p0/view_p0.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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;"
}
Loading