Fix wrong aggregate result when aggregation is pushdown to decoder
This commit is contained in:
@ -806,7 +806,7 @@ int ObIntegerColumnDecoder::traverse_integer_in_agg(
|
||||
// if agg_val less than base, no need to update min
|
||||
// if agg_val larger than RANGE_MAX_VALUE, no need to update max
|
||||
} else {
|
||||
uint64_t result = 0;
|
||||
uint64_t result = agg_cell.is_min_agg() ? UINT64_MAX : 0;
|
||||
bool result_is_null = false;
|
||||
if (use_null_replace_val) {
|
||||
const uint64_t null_replaced_val_base_diff = ctx.null_replaced_value_ - base_value;
|
||||
|
@ -1651,10 +1651,14 @@ class RawAggFunctionImpl
|
||||
const DataType *start_pos = reinterpret_cast<const DataType *>(raw_data);
|
||||
const DataType *a_end = start_pos + to;
|
||||
const DataType * __restrict a_pos = start_pos + from;
|
||||
DataType res_value = *(start_pos + from);
|
||||
DataType res_value = null_value;
|
||||
while (a_pos < a_end) {
|
||||
if (*a_pos != null_value && Op::apply(*a_pos, res_value)) {
|
||||
res_value = *a_pos;
|
||||
if (*a_pos != null_value) {
|
||||
if (res_value == null_value) {
|
||||
res_value = *a_pos;
|
||||
} else if (Op::apply(*a_pos, res_value)) {
|
||||
res_value = *a_pos;
|
||||
}
|
||||
}
|
||||
++a_pos;
|
||||
}
|
||||
@ -1662,6 +1666,7 @@ class RawAggFunctionImpl
|
||||
}))
|
||||
|
||||
// can use SIMD
|
||||
// Make sure that: res = 0 for min, res = UINT64_MAX for max
|
||||
OB_MULTITARGET_FUNCTION_AVX2_SSE42(
|
||||
OB_MULTITARGET_FUNCTION_HEADER(static void), raw_min_max_function_with_null_bitmap, OB_MULTITARGET_FUNCTION_BODY((
|
||||
const unsigned char* raw_data,
|
||||
@ -1674,15 +1679,13 @@ class RawAggFunctionImpl
|
||||
const DataType *a_end = start_pos + to;
|
||||
const DataType * __restrict a_pos = start_pos + from;
|
||||
const uint8_t * __restrict b_pos = null_bitmap;
|
||||
DataType res_value = *(start_pos + from);
|
||||
while (a_pos < a_end) {
|
||||
if (!*b_pos && Op::apply(*a_pos, res_value)) {
|
||||
res_value = *a_pos;
|
||||
if (!*b_pos && Op::apply(*a_pos, res)) {
|
||||
res = *a_pos;
|
||||
}
|
||||
++a_pos;
|
||||
++b_pos;
|
||||
}
|
||||
res = res_value;
|
||||
}))
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user