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& 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 59d6dcb851..9fae6ed634 100644 --- a/be/src/vec/exprs/lambda_function/varray_filter_function.cpp +++ b/be/src/vec/exprs/lambda_function/varray_filter_function.cpp @@ -60,7 +60,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& children) override { ///* array_filter(array, array) */// 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 2d305af7b6..2f57ed8976 100644 --- a/be/src/vec/exprs/lambda_function/varray_map_function.cpp +++ b/be/src/vec/exprs/lambda_function/varray_map_function.cpp @@ -60,7 +60,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& children) override { ///* array_map(lambda,arg1,arg2,.....) */// @@ -138,6 +138,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)); @@ -156,6 +162,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( @@ -167,6 +174,21 @@ public: } block->insert(std::move(result_arr)); *result_column_id = block->columns() - 1; + //check nullable(nested) + DCHECK((assert_cast( + (((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( + (((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 a2c839d42f..42aefece3a 100644 --- a/gensrc/script/doris_builtins_functions.py +++ b/gensrc/script/doris_builtins_functions.py @@ -631,7 +631,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']], [['array_filter'], 'ARRAY_BOOLEAN',['ARRAY_BOOLEAN', 'ARRAY_BOOLEAN'], ''], [['array_filter'], 'ARRAY_TINYINT',['ARRAY_TINYINT', 'ARRAY_BOOLEAN'], ''], [['array_filter'], 'ARRAY_SMALLINT',['ARRAY_SMALLINT', 'ARRAY_BOOLEAN'], ''],