[Vectorized](function) support order by convert_to function (#14555)

This commit is contained in:
zhangstar333
2022-11-29 15:22:27 +08:00
committed by GitHub
parent facb7cf4e2
commit 7a08a799e9
8 changed files with 255 additions and 2 deletions

View File

@ -5861,6 +5861,13 @@ non_pred_expr ::=
{: RESULT = new CastExpr(targetType, e); :}
| KW_KEY encryptkey_name:name
{: RESULT = new EncryptKeyRef(name); :}
| KW_CONVERT LPAREN expr:e KW_USING ident:character RPAREN
{:
ArrayList<Expr> exprs = new ArrayList<>();
exprs.add(e);
exprs.add(new StringLiteral(character));
RESULT = new FunctionCallExpr("convert_to", new FunctionParams(exprs));
:}
;
expr_pipe_list ::=

View File

@ -606,7 +606,6 @@ public class FunctionCallExpr extends Expr {
}
return;
}
if (fnName.getFunction().equalsIgnoreCase("group_concat")) {
if (children.size() - orderByElements.size() > 2 || children.isEmpty()) {
throw new AnalysisException(
@ -1229,7 +1228,13 @@ public class FunctionCallExpr extends Expr {
}
}
}
if (fnName.getFunction().equalsIgnoreCase("convert_to")) {
if (children.size() < 2 || !getChild(1).isConstant()) {
throw new AnalysisException(
fnName.getFunction() + " needs two params, and the second is must be a constant: " + this
.toSql());
}
}
if (fn.getFunctionName().getFunction().equals("timediff")) {
fn.getReturnType().getPrimitiveType().setTimeType();
}