[feature][vectorized] support table function explode_numbers() (#8509)

This commit is contained in:
Pxl
2022-03-22 11:38:00 +08:00
committed by GitHub
parent 989e03ddf9
commit be3d203289
23 changed files with 324 additions and 115 deletions

View File

@ -82,15 +82,14 @@ public class FunctionCallExpr extends Expr {
.add("variance").add("variance_pop").add("variance_pop").add("var_samp").add("var_pop").build();
private static final String ELEMENT_EXTRACT_FN_NAME = "%element_extract%";
//use to record the num of json_object parameters
// use to record the num of json_object parameters
private int originChildSize;
// Save the functionCallExpr in the original statement
private Expr originStmtFnExpr;
private boolean isRewrote = false;
public static final String UNKNOWN_TABLE_FUNCTION_MSG = "Currently only support `explode_split`, `explode_bitmap` " +
"and `explode_json_array_xx` table functions";
public static final String UNKNOWN_TABLE_FUNCTION_MSG = "This table function not supported now";
public void setIsAnalyticFnCall(boolean v) {
isAnalyticFnCall = v;
@ -184,7 +183,7 @@ public class FunctionCallExpr extends Expr {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < children.size(); ++i) {
Type type = getChild(i).getType();
if (type.isNull()) { //Not to return NULL directly, so save string, but flag is '0'
if (type.isNull()) { // Not to return NULL directly, so save string, but flag is '0'
if (((i & 1) == 0) && useKeyCheck == true) {
throw new AnalysisException("json_object key can't be NULL: " + this.toSql());
}

View File

@ -2309,6 +2309,7 @@ public class FunctionSet<min_initIN9doris_udf12DecimalV2ValEEEvPNS2_15FunctionCo
public static final String EXPLODE_JSON_ARRAY_INT = "explode_json_array_int";
public static final String EXPLODE_JSON_ARRAY_DOUBLE = "explode_json_array_double";
public static final String EXPLODE_JSON_ARRAY_STRING = "explode_json_array_string";
public static final String EXPLODE_NUMBERS = "explode_numbers";
private void initTableFunction() {
List<Function> explodeSplits = Lists.newArrayList();
@ -2350,5 +2351,13 @@ public class FunctionSet<min_initIN9doris_udf12DecimalV2ValEEEvPNS2_15FunctionCo
"_ZN5doris19DummyTableFunctions25explode_json_array_stringEPN9doris_udf15FunctionContextERKNS1_9StringValE",
null, null, true));
tableFunctions.put(EXPLODE_JSON_ARRAY_STRING, explodeJsonArrayStrings);
List<Function> explodeNumbers = Lists.newArrayList();
explodeNumbers.add(ScalarFunction.createBuiltin(
EXPLODE_NUMBERS, Type.INT, Function.NullableMode.DEPEND_ON_ARGUMENT,
Lists.newArrayList(Type.INT), false,
"_ZN5doris19DummyTableFunctions22explode_numbersEPN9doris_udf15FunctionContextERKNS1_9IntValE",
null, null, true));
tableFunctions.put(EXPLODE_NUMBERS, explodeNumbers);
}
}