[function](string) support char function (#18878)

* [function](string) support char function

* fix
This commit is contained in:
TengJianPing
2023-04-22 08:36:48 +08:00
committed by GitHub
parent de0e89d1b4
commit b75f4c97f3
11 changed files with 656 additions and 7 deletions

View File

@ -1444,6 +1444,19 @@ public class FunctionCallExpr extends Expr {
.toSql());
}
}
if (fnName.getFunction().equalsIgnoreCase("char")) {
if (!getChild(0).isConstant()) {
throw new AnalysisException(
fnName.getFunction() + " charset name must be a constant: " + this
.toSql());
}
LiteralExpr literal = (LiteralExpr) getChild(0);
if (!literal.getStringValue().equalsIgnoreCase("utf8")) {
throw new AnalysisException(
fnName.getFunction() + " function currently only support charset name 'utf8': " + this
.toSql());
}
}
if (fn.getFunctionName().getFunction().equals("timediff")) {
fn.getReturnType().getPrimitiveType().setTimeType();
}
@ -1500,6 +1513,10 @@ public class FunctionCallExpr extends Expr {
ix = i % 2 == 0 ? 0 : 1;
}
if (i == 0 && (fnName.getFunction().equalsIgnoreCase("char"))) {
continue;
}
if ((fnName.getFunction().equalsIgnoreCase("money_format") || fnName.getFunction()
.equalsIgnoreCase("histogram")
|| fnName.getFunction().equalsIgnoreCase("hist"))