Fix window function parallel bug

This commit is contained in:
qianchanger
2022-03-04 11:46:14 +08:00
committed by LINxiansheng
parent f0d7d9d626
commit ab74cf7478
2 changed files with 17 additions and 6 deletions

View File

@ -3122,11 +3122,16 @@ int ObAggregateCalcFunc::add_calc(const ObDatum& left_value, const ObDatum& righ
break; break;
} }
case ObNumberTC: { case ObNumberTC: {
if (left_value.is_null() && OB_FAIL(clone_number_cell(right_value.get_number(), result_datum, out_allocator))) { if (left_value.is_null()) {
if (OB_FAIL(clone_number_cell(right_value.get_number(),
result_datum, out_allocator))) {
LOG_WARN("fail to clone number cell", K(ret)); LOG_WARN("fail to clone number cell", K(ret));
} else if (right_value.is_null() && }
OB_FAIL(clone_number_cell(left_value.get_number(), result_datum, out_allocator))) { } else if (right_value.is_null()) {
if (OB_FAIL(clone_number_cell(left_value.get_number(),
result_datum, out_allocator))) {
LOG_WARN("fail to clone number cell", K(ret)); LOG_WARN("fail to clone number cell", K(ret));
}
} else { } else {
char buf_alloc[ObNumber::MAX_CALC_BYTE_LEN]; char buf_alloc[ObNumber::MAX_CALC_BYTE_LEN];
ObDataBuffer allocator(buf_alloc, ObNumber::MAX_CALC_BYTE_LEN); ObDataBuffer allocator(buf_alloc, ObNumber::MAX_CALC_BYTE_LEN);

View File

@ -1364,7 +1364,12 @@ int ObWindowFunctionOp::parallel_winbuf_process()
ObDatum& l_datum = new_row->cells()[idx]; ObDatum& l_datum = new_row->cells()[idx];
const ObDatum& r_datum = row->cells()[idx]; const ObDatum& r_datum = row->cells()[idx];
ObDatumCmpFuncType cmp_func = cmp_funcs.at(cmp_index); ObDatumCmpFuncType cmp_func = cmp_funcs.at(cmp_index);
if (cmp_func(l_datum, r_datum) < 0) { // null-last cmp func should ignore null in max calc
if (r_datum.is_null() && !l_datum.is_null()) {
/*do nothing*/
} else if (!r_datum.is_null() && l_datum.is_null()) {
l_datum = r_datum;
} else if (cmp_func(l_datum, r_datum) < 0) {
l_datum = r_datum; l_datum = r_datum;
} }
cmp_index++; cmp_index++;
@ -1374,6 +1379,7 @@ int ObWindowFunctionOp::parallel_winbuf_process()
ObDatum& l_datum = new_row->cells()[idx]; ObDatum& l_datum = new_row->cells()[idx];
const ObDatum& r_datum = row->cells()[idx]; const ObDatum& r_datum = row->cells()[idx];
ObDatumCmpFuncType cmp_func = cmp_funcs.at(cmp_index); ObDatumCmpFuncType cmp_func = cmp_funcs.at(cmp_index);
// null-last cmp func no need null special calc in min calc
if (cmp_func(l_datum, r_datum) > 0) { if (cmp_func(l_datum, r_datum) > 0) {
l_datum = r_datum; l_datum = r_datum;
} }