[feature-wip](array-type) support explode and explode_outer table function (#8766)
explode(ArrayColumn) desc: > Create a row for each element in the array column. explode_outer(ArrayColumn) desc: > Create a row for each element in the array column. Unlike explode, if the array is null or empty, it returns null. Usage example: 1. create a table with array column, and insert some data; 2. open enable_lateral_view and enable_vectorized_engine; ``` set enable_lateral_view = true; set enable_vectorized_engine=true; ``` 3. use explode_outer ``` > select * from array_test; +------+------+--------+ | k1 | k2 | k3 | +------+------+--------+ | 3 | NULL | NULL | | 1 | 2 | [1, 2] | | 2 | 3 | NULL | | 4 | NULL | [] | +------+------+--------+ > select k1,explode_column from array_test LATERAL VIEW explode_outer(k3) TempExplodeView as explode_column; +------+----------------+ | k1 | explode_column | +------+----------------+ | 1 | 1 | | 1 | 2 | | 2 | NULL | | 4 | NULL | | 3 | NULL | +------+----------------+ ``` 4. explode usage example. explode return empty rows while the ARRAY is null or empty ``` > select k1,explode_column from array_test LATERAL VIEW explode(k3) TempExplodeView as explode_column; +------+----------------+ | k1 | explode_column | +------+----------------+ | 1 | 1 | | 1 | 2 | +------+----------------+ ```
This commit is contained in:
@ -98,6 +98,9 @@ public:
|
||||
_vexpr_context = vexpr_context;
|
||||
}
|
||||
|
||||
bool is_outer() const { return _is_outer; }
|
||||
bool current_empty() const { return _is_current_empty; }
|
||||
|
||||
protected:
|
||||
std::string _fn_name;
|
||||
ExprContext* _expr_context = nullptr;
|
||||
@ -111,6 +114,8 @@ protected:
|
||||
int64_t _cur_offset = 0;
|
||||
// the size of current result
|
||||
int64_t _cur_size = 0;
|
||||
// set _is_outer to false for explode function, and should not return tuple while array is null or empty
|
||||
bool _is_outer = true;
|
||||
};
|
||||
|
||||
} // namespace doris
|
||||
|
||||
Reference in New Issue
Block a user