@@ -40,7 +40,7 @@ class ArrayMapFunction : public LambdaFunction {
40
40
std::string get_name () const override { return name; }
41
41
42
42
doris::Status execute (VExprContext* context, doris::vectorized::Block* block,
43
- int * result_column_id, DataTypePtr result_type,
43
+ int * result_column_id, const DataTypePtr& result_type,
44
44
const std::vector<VExpr*>& children) override {
45
45
// /* array_map(lambda,arg1,arg2,.....) *///
46
46
@@ -118,6 +118,12 @@ class ArrayMapFunction : public LambdaFunction {
118
118
" R" + array_column_type_name.name };
119
119
lambda_block.insert (std::move (data_column));
120
120
}
121
+ // check nullable(array(nullable(nested)))
122
+ DCHECK (result_type->is_nullable () &&
123
+ is_array (((DataTypeNullable*)result_type.get ())->get_nested_type ()))
124
+ << " array_map result type is error, now must be nullable(array): "
125
+ << result_type->get_name ()
126
+ << " ,and block structure is: " << block->dump_structure ();
121
127
122
128
// 3. child[0]->execute(new_block)
123
129
RETURN_IF_ERROR (children[0 ]->execute (context, &lambda_block, result_column_id));
@@ -136,6 +142,7 @@ class ArrayMapFunction : public LambdaFunction {
136
142
result_type, res_name};
137
143
138
144
} else {
145
+ // deal with eg: select array_map(x -> x is null, [null, 1, 2]);
139
146
// need to create the nested column null map for column array
140
147
auto nested_null_map = ColumnUInt8::create (res_col->size (), 0 );
141
148
result_arr = {ColumnNullable::create (
@@ -147,6 +154,21 @@ class ArrayMapFunction : public LambdaFunction {
147
154
}
148
155
block->insert (std::move (result_arr));
149
156
*result_column_id = block->columns () - 1 ;
157
+ // check nullable(nested)
158
+ DCHECK ((assert_cast<const DataTypeArray*>(
159
+ (((DataTypeNullable*)result_type.get ())->get_nested_type ().get ())))
160
+ ->get_nested_type ()
161
+ ->equals (*make_nullable (res_type)))
162
+ << " array_map function FE given result type is: " << result_type->get_name ()
163
+ << " get nested is: "
164
+ << (assert_cast<const DataTypeArray*>(
165
+ (((DataTypeNullable*)result_type.get ())->get_nested_type ().get ())))
166
+ ->get_nested_type ()
167
+ ->get_name ()
168
+ << " and now actual nested type after calculate " << res_type->get_name ()
169
+ << " ,and block structure is: " << block->dump_structure ()
170
+ << " ,and lambda_block structure is: " << lambda_block.dump_structure ();
171
+
150
172
return Status::OK ();
151
173
}
152
174
};
0 commit comments