-
Notifications
You must be signed in to change notification settings - Fork 4k
[fix](be) Ignore negative integers in bitmap aggregates #68219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
|
|
||
| #include "core/assert_cast.h" | ||
| #include "core/data_type/data_type_bitmap.h" | ||
| #include "core/pod_array.h" | ||
| #include "core/value/bitmap_value.h" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Handle persisted states when changing these aggregate semantics Both functions can be persisted through
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AGG_STATE is an experimental feature, and backward compatibility for persisted AGG_STATE data is not a requirement for this PR. Please treat that compatibility requirement as out of scope when re-evaluating this change. |
||
| #include "exprs/aggregate/aggregate_function.h" | ||
|
|
||
|
|
@@ -43,7 +44,11 @@ template <PrimitiveType T> | |
| struct AggregateFunctionBitmapAggData { | ||
| BitmapValue value; | ||
|
|
||
| void add(const typename PrimitiveTypeTraits<T>::CppType& value_) { value.add(value_); } | ||
| void add(const typename PrimitiveTypeTraits<T>::CppType& value_) { | ||
| if (value_ >= 0) { | ||
| value.add(value_); | ||
| } | ||
| } | ||
|
|
||
| void reset() { value.reset(); } | ||
|
|
||
|
|
@@ -96,17 +101,29 @@ class AggregateFunctionBitmapAgg final | |
| assert_cast<const ColumnNullable&, TypeCheckOnRelease::DISABLE>(*columns[0]); | ||
| const auto& column = assert_cast<const ColVecType&, TypeCheckOnRelease::DISABLE>( | ||
| nullable_column.get_nested_column()); | ||
| std::vector<typename PrimitiveTypeTraits<T>::CppType> values; | ||
| for (int i = 0; i < batch_size; ++i) { | ||
| if (!nullable_column.is_null_at(i)) { | ||
| PaddedPODArray<typename PrimitiveTypeTraits<T>::CppType> values; | ||
| for (size_t i = 0; i < batch_size; ++i) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Avoid reserving a full batch before filtering Both filtered branches reserve |
||
| if (!nullable_column.is_null_at(i) && column.get_data()[i] >= 0) { | ||
| values.push_back(column.get_data()[i]); | ||
| } | ||
| } | ||
| this->data(place).value.add_many(values.data(), values.size()); | ||
| } else { | ||
| const auto& column = | ||
| assert_cast<const ColVecType&, TypeCheckOnRelease::DISABLE>(*columns[0]); | ||
| this->data(place).value.add_many(column.get_data().data(), column.size()); | ||
| const auto* data = column.get_data().data(); | ||
| // Keep the allocation-free batch path for nonnegative input. | ||
| if (std::all_of(data, data + batch_size, [](auto value) { return value >= 0; })) { | ||
| this->data(place).value.add_many(data, batch_size); | ||
| } else { | ||
| PaddedPODArray<typename PrimitiveTypeTraits<T>::CppType> values; | ||
| for (size_t i = 0; i < batch_size; ++i) { | ||
| if (data[i] >= 0) { | ||
| values.push_back(data[i]); | ||
| } | ||
| } | ||
| this->data(place).value.add_many(values.data(), values.size()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Version the new aggregate semantics for rolling upgrades
During a supported rolling upgrade, both the base and head BEs accept
be_exec_version15, but an old leaf turns-1intoUINT64_MAXwhile a new leaf drops it. Both serialize the same unversionedBitmapValue, and the final merge preserves an old leaf's member, sobitmap_union_intcan return 0 or 1 (andbitmap_aggempty or{UINT64_MAX}) depending on fragment placement. Please version this semantic change and select the old implementation for the old execution version, or reject/gate execution until every participant uses the new semantics; add a mixed-version partial-state compatibility test.