[fix](window_function) min/max/sum/avg should be always nullable (#27104)
Co-authored-by: starocean999 <40539150+starocean999@users.noreply.github.com>
This commit is contained in:
@ -639,6 +639,19 @@ void VAnalyticEvalNode::_insert_result_info(int64_t current_block_rows) {
|
||||
|
||||
for (int i = 0; i < _agg_functions_size; ++i) {
|
||||
for (int j = get_result_start; j < _window_end_position; ++j) {
|
||||
if (!_agg_functions[i]->function()->get_return_type()->is_nullable() &&
|
||||
_result_window_columns[i]->is_nullable()) {
|
||||
if (_current_window_empty) {
|
||||
_result_window_columns[i]->insert_default();
|
||||
} else {
|
||||
auto* dst = assert_cast<ColumnNullable*>(_result_window_columns[i].get());
|
||||
dst->get_null_map_data().push_back(0);
|
||||
_agg_functions[i]->insert_result_info(
|
||||
_fn_place_ptr + _offsets_of_aggregate_states[i],
|
||||
&dst->get_nested_column());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
_agg_functions[i]->insert_result_info(_fn_place_ptr + _offsets_of_aggregate_states[i],
|
||||
_result_window_columns[i].get());
|
||||
}
|
||||
@ -683,6 +696,10 @@ void VAnalyticEvalNode::_execute_for_win_func(int64_t partition_start, int64_t p
|
||||
partition_start, partition_end, frame_start, frame_end,
|
||||
_fn_place_ptr + _offsets_of_aggregate_states[i], _agg_columns.data(), nullptr);
|
||||
}
|
||||
|
||||
// If the end is not greater than the start, the current window should be empty.
|
||||
_current_window_empty =
|
||||
std::min(frame_end, partition_end) <= std::max(frame_start, partition_start);
|
||||
}
|
||||
|
||||
//binary search for range to calculate peer group
|
||||
|
||||
Reference in New Issue
Block a user