This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch branch-2.0-alpha in repository https://gitbox.apache.org/repos/asf/doris.git
commit e6fecabebbaceb1276dfcfddedb57b2140f9d769 Author: Kang <[email protected]> AuthorDate: Sun Apr 30 23:32:21 2023 +0800 [vectorized](function) add some check about result type in array map #19228 --- be/src/vec/exprs/lambda_function/lambda_function.h | 2 +- .../lambda_function/varray_filter_function.cpp | 2 +- .../exprs/lambda_function/varray_map_function.cpp | 24 +++++++++++++++++++++- gensrc/script/doris_builtins_functions.py | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/be/src/vec/exprs/lambda_function/lambda_function.h b/be/src/vec/exprs/lambda_function/lambda_function.h index a1eb173725..a7f2fb8f69 100644 --- a/be/src/vec/exprs/lambda_function/lambda_function.h +++ b/be/src/vec/exprs/lambda_function/lambda_function.h @@ -32,7 +32,7 @@ public: virtual std::string get_name() const = 0; virtual doris::Status execute(VExprContext* context, doris::vectorized::Block* block, - int* result_column_id, DataTypePtr result_type, + int* result_column_id, const DataTypePtr& result_type, const std::vector<VExpr*>& children) = 0; }; diff --git a/be/src/vec/exprs/lambda_function/varray_filter_function.cpp b/be/src/vec/exprs/lambda_function/varray_filter_function.cpp index 8d4acdf8f8..636ee709c2 100644 --- a/be/src/vec/exprs/lambda_function/varray_filter_function.cpp +++ b/be/src/vec/exprs/lambda_function/varray_filter_function.cpp @@ -42,7 +42,7 @@ public: std::string get_name() const override { return name; } doris::Status execute(VExprContext* context, doris::vectorized::Block* block, - int* result_column_id, DataTypePtr result_type, + int* result_column_id, const DataTypePtr& result_type, const std::vector<VExpr*>& children) override { ///* array_filter(array, array<boolean>) */// diff --git a/be/src/vec/exprs/lambda_function/varray_map_function.cpp b/be/src/vec/exprs/lambda_function/varray_map_function.cpp index 5fac25ca3f..e2fedd0cb6 100644 --- a/be/src/vec/exprs/lambda_function/varray_map_function.cpp +++ b/be/src/vec/exprs/lambda_function/varray_map_function.cpp @@ -40,7 +40,7 @@ public: std::string get_name() const override { return name; } doris::Status execute(VExprContext* context, doris::vectorized::Block* block, - int* result_column_id, DataTypePtr result_type, + int* result_column_id, const DataTypePtr& result_type, const std::vector<VExpr*>& children) override { ///* array_map(lambda,arg1,arg2,.....) */// @@ -118,6 +118,12 @@ public: "R" + array_column_type_name.name}; lambda_block.insert(std::move(data_column)); } + //check nullable(array(nullable(nested))) + DCHECK(result_type->is_nullable() && + is_array(((DataTypeNullable*)result_type.get())->get_nested_type())) + << "array_map result type is error, now must be nullable(array): " + << result_type->get_name() + << " ,and block structure is: " << block->dump_structure(); //3. child[0]->execute(new_block) RETURN_IF_ERROR(children[0]->execute(context, &lambda_block, result_column_id)); @@ -136,6 +142,7 @@ public: result_type, res_name}; } else { + // deal with eg: select array_map(x -> x is null, [null, 1, 2]); // need to create the nested column null map for column array auto nested_null_map = ColumnUInt8::create(res_col->size(), 0); result_arr = {ColumnNullable::create( @@ -147,6 +154,21 @@ public: } block->insert(std::move(result_arr)); *result_column_id = block->columns() - 1; + //check nullable(nested) + DCHECK((assert_cast<const DataTypeArray*>( + (((DataTypeNullable*)result_type.get())->get_nested_type().get()))) + ->get_nested_type() + ->equals(*make_nullable(res_type))) + << " array_map function FE given result type is: " << result_type->get_name() + << " get nested is: " + << (assert_cast<const DataTypeArray*>( + (((DataTypeNullable*)result_type.get())->get_nested_type().get()))) + ->get_nested_type() + ->get_name() + << " and now actual nested type after calculate " << res_type->get_name() + << " ,and block structure is: " << block->dump_structure() + << " ,and lambda_block structure is: " << lambda_block.dump_structure(); + return Status::OK(); } }; diff --git a/gensrc/script/doris_builtins_functions.py b/gensrc/script/doris_builtins_functions.py index 90e8a87397..409326f1f6 100644 --- a/gensrc/script/doris_builtins_functions.py +++ b/gensrc/script/doris_builtins_functions.py @@ -619,7 +619,7 @@ visible_functions = [ [['array_popfront'], 'ARRAY_DECIMAL128', ['ARRAY_DECIMAL128'], ''], [['array_popfront'], 'ARRAY_VARCHAR', ['ARRAY_VARCHAR'], ''], [['array_popfront'], 'ARRAY_STRING', ['ARRAY_STRING'], ''], - [['array_map'], 'ARRAY', ['LAMBDA_FUNCTION', 'ARRAY', '...'], ''], + [['array_map'], 'ARRAY', ['LAMBDA_FUNCTION', 'ARRAY<K>', '...'], '', ['K']], [['array_filter'], 'ARRAY_BOOLEAN',['ARRAY_BOOLEAN', 'ARRAY_BOOLEAN'], ''], [['array_filter'], 'ARRAY_TINYINT',['ARRAY_TINYINT', 'ARRAY_BOOLEAN'], ''], [['array_filter'], 'ARRAY_SMALLINT',['ARRAY_SMALLINT', 'ARRAY_BOOLEAN'], ''], --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
