[vectorized](function) add some check about result type in array map #19228
diff --git a/be/src/vec/exprs/lambda_function/lambda_function.h b/be/src/vec/exprs/lambda_function/lambda_function.h
index a1eb173..a7f2fb8 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 @@
     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 8d4acdf..636ee70 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 @@
     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 5fac25c..e2fedd0 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 @@
     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 @@
                                                "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 @@
                           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 @@
         }
         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 90e8a87..409326f 100644
--- a/gensrc/script/doris_builtins_functions.py
+++ b/gensrc/script/doris_builtins_functions.py
@@ -619,7 +619,7 @@
     [['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'], ''],