[FIX](explode)fix explode array decimal (#28744)

* fix explode with array<decimal> has specific precision at old planner
This commit is contained in:
amory
2023-12-20 20:19:56 +08:00
committed by GitHub
parent 280a01b815
commit a8dcca98ec
5 changed files with 98 additions and 2 deletions

View File

@ -1618,8 +1618,25 @@ public class FunctionCallExpr extends Expr {
// now first find table function in table function sets
if (isTableFnCall) {
Type[] childTypes = collectChildReturnTypes();
fn = getTableFunction(fnName.getFunction(), childTypes,
Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
// when we call explode<Array<Decimal>> with nested decimal has specific precision and scale,
// collectChildReturnTypes will return specific precision and scale decimal type witch may not match
// builtln func we defined in fe code, because we make array_support_type is actual origin type.here we
// temp write this if to get matched explode function and then set actually decimal type from sql to
// func return type. if we switch nereid would hasn't this problems.
if (fnName.getFunction().equalsIgnoreCase("explode") && childTypes[0].isArrayType()) {
// get origin type to match builtln func
Type[] matchFuncChildTypes = getActualArgTypes(childTypes);
fn = getTableFunction(fnName.getFunction(), matchFuncChildTypes,
Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
if (fn == null) {
throw new AnalysisException(getFunctionNotFoundError(argTypes));
}
// set param child types
fn.setReturnType(((ArrayType) childTypes[0]).getItemType());
} else {
fn = getTableFunction(fnName.getFunction(), childTypes,
Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
}
if (fn == null) {
throw new AnalysisException(getFunctionNotFoundError(argTypes));
}

View File

@ -1772,6 +1772,9 @@ public class FunctionSet<T> {
Lists.newArrayList(new ArrayType(subType)), false,
"_ZN5doris19DummyTableFunctions7explodeEPN9doris_udf15FunctionContextERKNS1_13CollectionValE");
}
addTableFunctionWithCombinator(EXPLODE, Type.WILDCARD_DECIMAL, Function.NullableMode.ALWAYS_NULLABLE,
Lists.newArrayList(new ArrayType(Type.WILDCARD_DECIMAL)), false,
"_ZN5doris19DummyTableFunctions7explodeEPN9doris_udf15FunctionContextERKNS1_13CollectionValE");
}
public boolean isAggFunctionName(String name) {