hello-stephen commented on code in PR #69304:
URL: https://github.com/apache/doris/pull/69304#discussion_r4789030711
##########
fe/fe-common/src/main/java/org/apache/doris/common/Config.java:
##########
@@ -2114,8 +2114,13 @@ public class Config extends ConfigBase {
// file-local one and fetch the wrong rows. The lance connector keeps its
own copy of this number.
public static final int LANCE_ROW_LOCATION_MIN_BE_EXEC_VERSION = 20;
+ // Version 20 adds Lance row locations and retains the existing nullable
intermediate protocols.
+ // Unary requests with the old V2 flag can still use native columns below
version 21.
+ // Version 21 unifies the native protocol for unary and variadic nullable
aggregation.
+ public static final int UNIFIED_NULLABLE_AGGREGATION_MIN_BE_EXEC_VERSION =
21;
Review Comment:
[P2] Include the execution version in SQL result-cache compatibility
With SQL caching enabled and an unchanged OLAP table `src(p)` containing `0`
and `7`, cache `SELECT
bitmap_to_string(bitmap_intersect_merge(bitmap_intersect_state(IF(p = 0, NULL,
to_bitmap(p))))) FROM src` while `be_exec_version` is pinned to 20. The NULL
row produces a real empty bitmap, so the result is empty. Raising the pin to 21
makes a fresh execution return `7`, because the NULL row now produces the
no-input marker. `ConnectProcessor.parseFromSqlCache` can reuse the old result
before planning. The lookup and BE digest in `NereidsSqlCacheManager` and
`SqlCacheContext` omit the execution version, and
`Env.setMutableConfigWithCallback` leaves the cache valid. Make the producing
execution version part of cache admission and lookup so a version change forces
a fresh result.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/AggStateType.java:
##########
@@ -219,7 +365,9 @@ public boolean equals(Object o) {
}
AggStateType rhs = (AggStateType) o;
- return returnNullable == rhs.returnNullable
+ // Keep codec differences visible so the sink retains its target
conversion.
+ return beExecVersion == rhs.beExecVersion
Review Comment:
[P2] Allow RESTORE into an existing table with a byte-compatible state codec
A backup of a v20 table with `AGG_STATE<SUM(BIGINT NULL)>` can no longer be
restored into an otherwise identical existing v21 table without force
replacement. `RestoreJob.aggStateSignatures()` maps the columns to Nereids
types and the existing-table check compares those maps with `equals()`, so this
new comparison reports a different schema even though the v20 and v21 SUM
payloads are identical. At the restore boundary, check whether the target can
read the backup's rowset bytes directly. Keep rejecting cases that would
require a payload rewrite.
##########
fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java:
##########
@@ -1010,6 +1011,18 @@ private boolean processModifyColumn(ModifyColumnOp
modifyColumnOp, OlapTable ola
if (col.getName().equalsIgnoreCase(newColName)) {
modColIndex = i;
found = true;
+ if (col.getType() instanceof AggStateType &&
modColumn.getType() instanceof AggStateType
+ && ((org.apache.doris.nereids.types.AggStateType)
DataType.fromCatalogType(col.getType()))
+
.hasSameAggregateSignature((org.apache.doris.nereids.types.AggStateType)
Review Comment:
[P2] Retain nested state codecs when MODIFY repeats the SQL type
Create a v21 column of type
`AGG_STATE<ANY_VALUE(AGG_STATE<BITMAP_INTERSECT(BITMAP NULL)> NOT NULL)>`, then
repeat its definition in a comment-only `MODIFY COLUMN` while the FE is pinned
to v20. `hasSameAggregateSignature()` compares nested types using
codec-sensitive equality, so this guard misses the unchanged declaration.
Schema-change validation then rejects the proposed type because the inner v21
bitmap marker cannot be converted inside an opaque ANY_VALUE payload. Compare
nested SQL signatures recursively and retain the complete old type when the
declaration matches.
##########
be/test/CMakeLists.txt:
##########
@@ -136,6 +136,14 @@ include_directories(
# Removed test files are added back using separate compile arguments.
add_subdirectory(storage/index/ann)
+if (DORIS_BE_UT_SOURCE_FILTER)
+ # Keep the normal test runner/support code while allowing a focused
compile-and-run loop.
+ # GTest's runtime filter alone still compiles unrelated test sources.
+ list(FILTER UT_FILES INCLUDE REGEX
Review Comment:
[P3] Apply the BE unit-test source filter to the ANN test archive
A narrow `DORIS_BE_UT_SOURCE_FILTER` still compiles and registers every ANN
test. Those sources are removed from `UT_FILES` earlier, then built in
`storage/index/ann` and linked as a whole archive. With no additional GTest
filter, they also run. Apply the source selection to the separate ANN test list
and omit its test archive when the filter selects none.
##########
be/src/exprs/aggregate/aggregate_function_legacy_nullable.h:
##########
@@ -0,0 +1,151 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#include <cstddef>
+#include <cstdint>
+#include <memory>
+#include <utility>
+
+#include "exprs/aggregate/aggregate_function.h"
+
+namespace doris {
+
+template <typename T>
+struct FunctionStableTransfer;
+
+// Published flag-plus-state String columns retain a separate codec, while
every
+// calculation delegates to V2. Keep the concrete function type so generic
batch
+// readers can inline create/decode/merge/destroy instead of making virtual
calls
+// for each state. Native readers retain their separate scratch capability.
+template <typename Function>
+class AggregateFunctionLegacyNullableState final
+ : public
IAggregateFunctionHelper<AggregateFunctionLegacyNullableState<Function>> {
+ using Base =
IAggregateFunctionHelper<AggregateFunctionLegacyNullableState<Function>>;
+
+public:
+ explicit AggregateFunctionLegacyNullableState(std::shared_ptr<Function>
function)
+ : Base(function->get_argument_types()),
_function(std::move(function)) {}
+
+ String get_name() const override { return _function->get_name(); }
+ IAggregateFunction* transmit_to_stable() override {
+ if (auto* stable = _function->transmit_to_stable()) {
+ using StableFunction = typename
FunctionStableTransfer<Function>::FunctionStable;
+ return new AggregateFunctionLegacyNullableState<StableFunction>(
+
std::shared_ptr<StableFunction>(assert_cast<StableFunction*>(stable)));
+ }
+ return nullptr;
+ }
+ DataTypePtr get_return_type() const override { return
_function->get_return_type(); }
+ void set_version(int version_) override {
+ Base::set_version(version_);
+ _function->set_version(version_);
+ }
+ void set_query_context(QueryContext* ctx) override {
_function->set_query_context(ctx); }
+ void set_ai_statistics(std::shared_ptr<AIExecutionStatistics> statistics)
override {
+ _function->set_ai_statistics(std::move(statistics));
+ }
+ bool is_blockable() const override { return _function->is_blockable(); }
+ // The byte format does not change how a window can spill its partition.
+ // For example, a version-19 nullable SUM still supports PARTITION_REDUCE.
+ WindowSpillStrategy window_spill_strategy() const override {
+ return _function->window_spill_strategy();
+ }
+ WindowSpillPeerFunction window_spill_peer_function() const override {
+ return _function->window_spill_peer_function();
+ }
+ bool supported_incremental_mode() const override {
+ return _function->supported_incremental_mode();
+ }
+ bool result_column_could_resize() const override {
+ return _function->result_column_could_resize();
+ }
+ void execute_function_with_incremental(int64_t partition_start, int64_t
partition_end,
+ int64_t frame_start, int64_t
frame_end,
+ AggregateDataPtr place, const
IColumn** columns,
+ Arena& arena, bool previous_is_nul,
bool end_is_nul,
+ bool has_null, UInt8*
use_null_result,
+ UInt8* could_use_previous_result)
const override {
+ _function->execute_function_with_incremental(
+ partition_start, partition_end, frame_start, frame_end, place,
columns, arena,
+ previous_is_nul, end_is_nul, has_null, use_null_result,
could_use_previous_result);
+ }
+ void insert_result_into_range(ConstAggregateDataPtr place, IColumn&
column, size_t start,
+ size_t end) const override {
+ _function->insert_result_into_range(place, column, start, end);
+ }
+ // Do not forward the native reader's scratch capability: this adapter
reads String
+ // columns through generic readers even when the nested function reads
native fixed states.
+ void create(AggregateDataPtr place) const override {
_function->create(place); }
+ void destroy(AggregateDataPtr place) const noexcept override {
_function->destroy(place); }
+ void reset(AggregateDataPtr place) const override {
_function->reset(place); }
+ bool is_trivial() const override { return _function->is_trivial(); }
+ size_t size_of_data() const override { return _function->size_of_data(); }
+ size_t align_of_data() const override { return _function->align_of_data();
}
+ void check_input_columns_type(const IColumn** columns) const override {
+ _function->check_input_columns_type(columns);
+ }
+ void check_result_column_type(const IColumn& column) const override {
+ _function->check_result_column_type(column);
+ }
+ void add(AggregateDataPtr place, const IColumn** columns, ssize_t row,
+ Arena& arena) const override {
+ _function->add(place, columns, row, arena);
+ }
+ void streaming_agg_serialize_to_column(const IColumn** columns,
MutableColumnPtr& dst,
+ size_t rows, Arena& arena) const
override {
+ _function->streaming_agg_serialize_to_column_legacy(columns, dst,
rows, arena);
+ }
+ void add_batch(size_t rows, AggregateDataPtr* places, size_t offset, const
IColumn** columns,
+ Arena& arena, bool agg_many) const override {
+ _function->add_batch(rows, places, offset, columns, arena, agg_many);
+ }
+ void add_batch_selected(size_t rows, AggregateDataPtr* places, size_t
offset,
+ const IColumn** columns, Arena& arena) const
override {
+ _function->add_batch_selected(rows, places, offset, columns, arena);
+ }
+ void add_batch_single_place(size_t rows, AggregateDataPtr place, const
IColumn** columns,
+ Arena& arena) const override {
+ _function->add_batch_single_place(rows, place, columns, arena);
+ }
+ void add_batch_range(size_t begin, size_t end, AggregateDataPtr place,
const IColumn** columns,
Review Comment:
[P3] Preserve the batched range path for legacy nullable windows
With `be_exec_version` pinned to 19 or 20, `SUM(nullable_v) OVER (PARTITION
BY k)` can reach the adapter through
`AnalyticSinkLocalState::_execute_for_function()` or partition-reduction spill.
The inherited `add_range_single_place()` calls `add()` for every row, testing
the null map and writing the validity flag on every iteration. The previous
nullable wrapper and native V2 check the null map once on a batch without NULLs
and dispatch to SUM's contiguous range loop. Forward `add_range_single_place()`
alongside `add_batch_range()` to retain that fast path.
##########
be/benchmark/benchmark_main.cpp:
##########
@@ -42,6 +44,7 @@
#include "benchmark_hybrid_set.hpp"
#include "benchmark_json_extract.hpp"
#include "benchmark_md5.hpp"
+#include "benchmark_nullable_aggregation.hpp"
Review Comment:
[P3] Keep the billion-row nullable benchmark sweep opt-in
This include registers the large AVG_WEIGHTED workload in the general
benchmark executable. With no environment override, `variadic_arguments()`
gives each of its 12 streaming and 24 merge variants 999,997,440 row operations
per iteration. An unfiltered run therefore adds roughly 36 billion row
operations even at one iteration per variant. Use a small default workload for
the general executable and reserve the large sweep for explicit selection.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]