This is an automated email from the ASF dual-hosted git repository.
HappenLee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 697ba8e3654 [chore](function) Remove the legacy map_agg_v1 aggregate
function (#68606)
697ba8e3654 is described below
commit 697ba8e3654475d44fcd8df3ad9e70bcad48a544
Author: Jerry Hu <[email protected]>
AuthorDate: Thu Oct 8 11:16:31 2026 +0800
[chore](function) Remove the legacy map_agg_v1 aggregate function (#68606)
Issue Number: None
Related PR: #51343
Problem Summary:
#51343 added `map_agg_v2`, which keeps NULL keys and handles NULL values
correctly, and made `map_agg` an alias of it. The old implementation
(`AggregateFunctionMapAgg`, exposed as `map_agg_v1`) was kept only so it
could still be called explicitly. It has no remaining callers, so this
PR
removes it:
- BE: delete `aggregate_function_map.h/.cpp` and its registration
(`map_agg_v1` and the BE-side `map_agg` -> `map_agg_v1` alias).
- FE: delete the `MapAgg` expression class, its `map_agg_v1` builtin
entry
and the `visitMapAgg` visitor method. `map_agg` keeps resolving to
`map_agg_v2` in FE.
- Tests: drop the v1-only regression suite and the v1-specific BE UT,
switch the agg_state column in the segment flusher format test to
`map_agg_v2`, and regenerate its golden Segments. The only byte that
changes in those Segments is the aggregate function name stored in the
column metadata (`map_agg_v1` -> `map_agg_v2`), plus the footer
checksum for V2 Segments.
After this change `SELECT map_agg_v1(...)` fails with
`Can not found function 'map_agg_v1'`.
Upgrade compatibility with agg_state columns created by old versions
(e.g. `agg_state<map_agg(...)>` created before `map_agg_v2` existed,
which BE resolved to the v1 implementation) is intentionally not kept.
### Release note
Remove the legacy aggregate function `map_agg_v1`. Use `map_agg` (the
same
as `map_agg_v2`) instead. `agg_state` columns built on the old `map_agg`
implementation are no longer readable and must be rebuilt.
### Check List (For Author)
- Test:
- Regression test: `query_p0/aggregate/map_agg` (adds a negative case
for `map_agg_v1`), `test_agg_state_map`, `agg_sync_mv`,
`map_agg_nested_insert_doris`, `map_agg_by_key`,
`test_mapagg_with_jsonfuncs`
- Unit Test: `AggFnEvaluatorTest.*`, `SegmentFlusherFormatTest.*`,
`SegmentFlusherTransformFormatTest.*`, `InferAggNotNullTest`
- Behavior changed: Yes (`map_agg_v1` is removed)
- Does this need documentation: Yes (the `map_agg_v1` entry in the
function docs
should be removed in doris-website; no doc PR yet)
---
be/src/exprs/aggregate/aggregate_function_map.cpp | 60 ----
be/src/exprs/aggregate/aggregate_function_map.h | 335 --------------------
.../aggregate_function_simple_factory.cpp | 2 -
be/test/exec/agg/agg_fn_evaluator_test.cpp | 29 --
.../storage/rowset/segment_flusher_format_test.cpp | 2 +-
.../segment_0.dat | Bin 5586 -> 5586 bytes
.../segment_1.dat | Bin 5588 -> 5588 bytes
.../segment_0.dat | Bin 5402 -> 5402 bytes
.../segment_1.dat | Bin 5404 -> 5404 bytes
.../segment_0.dat | Bin 5446 -> 5446 bytes
.../segment_1.dat | Bin 5258 -> 5258 bytes
.../segment_0.dat | Bin 5262 -> 5262 bytes
.../segment_1.dat | Bin 5074 -> 5074 bytes
.../segment_0.dat | Bin 5582 -> 5582 bytes
.../segment_1.dat | Bin 5582 -> 5582 bytes
.../segment_0.dat | Bin 5398 -> 5398 bytes
.../segment_1.dat | Bin 5398 -> 5398 bytes
.../segment_0.dat | Bin 5384 -> 5384 bytes
.../segment_1.dat | Bin 5161 -> 5161 bytes
.../segment_0.dat | Bin 5200 -> 5200 bytes
.../segment_1.dat | Bin 4977 -> 4977 bytes
.../doris/catalog/BuiltinAggregateFunctions.java | 2 -
.../trees/expressions/functions/agg/MapAgg.java | 83 -----
.../visitor/AggregateFunctionVisitor.java | 5 -
.../nereids/rules/rewrite/InferAggNotNullTest.java | 2 -
.../data/query_p0/aggregate/map_agg_v1.out | 50 ---
.../suites/query_p0/aggregate/map_agg.groovy | 7 +-
.../suites/query_p0/aggregate/map_agg_v1.groovy | 352 ---------------------
28 files changed, 7 insertions(+), 922 deletions(-)
diff --git a/be/src/exprs/aggregate/aggregate_function_map.cpp
b/be/src/exprs/aggregate/aggregate_function_map.cpp
deleted file mode 100644
index aa7ebd00fd8..00000000000
--- a/be/src/exprs/aggregate/aggregate_function_map.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-// 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.
-
-#include "exprs/aggregate/aggregate_function_map.h"
-
-#include "core/call_on_type_index.h"
-#include "exprs/aggregate/helpers.h"
-
-namespace doris {
-
-template <PrimitiveType K>
-AggregateFunctionPtr create_agg_function_map_agg(const DataTypes&
argument_types,
- const bool result_is_nullable,
- const AggregateFunctionAttr&
attr) {
- return creator_without_type::create_ignore_nullable<
- AggregateFunctionMapAgg<AggregateFunctionMapAggData<K>,
K>>(argument_types,
-
result_is_nullable, attr);
-}
-
-AggregateFunctionPtr create_aggregate_function_map_agg(const std::string& name,
- const DataTypes&
argument_types,
- const DataTypePtr&
result_type,
- const bool
result_is_nullable,
- const
AggregateFunctionAttr& attr) {
- AggregateFunctionPtr agg_fn;
- auto call = [&](const auto& type) -> bool {
- using DispatcType = std::decay_t<decltype(type)>;
- agg_fn =
create_agg_function_map_agg<DispatcType::PType>(argument_types,
result_is_nullable,
- attr);
- return true;
- };
-
- if (!dispatch_switch_all(argument_types[0]->get_primitive_type(), call)) {
- LOG(WARNING) << fmt::format("unsupported input type {} for aggregate
function {}",
- argument_types[0]->get_name(), name);
- return nullptr;
- }
- return agg_fn;
-}
-
-void register_aggregate_function_map_agg(AggregateFunctionSimpleFactory&
factory) {
- factory.register_function_both("map_agg_v1",
create_aggregate_function_map_agg);
- factory.register_alias("map_agg_v1", "map_agg");
-}
-
-} // namespace doris
\ No newline at end of file
diff --git a/be/src/exprs/aggregate/aggregate_function_map.h
b/be/src/exprs/aggregate/aggregate_function_map.h
deleted file mode 100644
index 6f901c965cf..00000000000
--- a/be/src/exprs/aggregate/aggregate_function_map.h
+++ /dev/null
@@ -1,335 +0,0 @@
-// 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 <parallel_hashmap/phmap.h>
-
-#include "core/assert_cast.h"
-#include "core/column/column_decimal.h"
-#include "core/column/column_map.h"
-#include "core/column/column_nullable.h"
-#include "core/column/column_string.h"
-#include "core/data_type/data_type_map.h"
-#include "core/string_ref.h"
-#include "core/types.h"
-#include "exprs/aggregate/aggregate_function.h"
-#include "exprs/aggregate/aggregate_function_simple_factory.h"
-
-namespace doris {
-
-template <PrimitiveType K>
-struct AggregateFunctionMapAggData {
- using KeyType = typename PrimitiveTypeTraits<K>::CppType;
- using Map = doris::flat_hash_map<StringRef, int64_t>;
-
- AggregateFunctionMapAggData() { throw
Exception(Status::FatalError("__builtin_unreachable")); }
-
- AggregateFunctionMapAggData(const DataTypes& argument_types) {
- _key_type = remove_nullable(argument_types[0]);
- _value_type = make_nullable(argument_types[1]);
- _key_column = _key_type->create_column();
- _value_column = _value_type->create_column();
- }
-
- void reset() {
- _map.clear();
- _key_column->clear();
- _value_column->clear();
- }
-
- void add(StringRef key, const Field& value) {
- DCHECK(key.data != nullptr);
- if (UNLIKELY(_map.find(key) != _map.end())) {
- return;
- }
-
- key.data = _arena.insert(key.data, key.size);
-
- _map.emplace(key, _key_column->size());
- _key_column->insert_data(key.data, key.size);
- _value_column->insert(value);
- }
-
- void add(const Field& key_, const Field& value) {
- DCHECK(!key_.is_null());
- auto key_array = key_.get<TYPE_ARRAY>();
- auto value_array = value.get<TYPE_ARRAY>();
-
- const auto count = key_array.size();
- DCHECK_EQ(count, value_array.size());
-
- for (size_t i = 0; i != count; ++i) {
- StringRef key;
- if constexpr (is_string_type(K)) {
- auto& string = key_array[i].get<K>();
- key.data = string.data();
- key.size = string.size();
- } else {
- auto& k = key_array[i].get<K>();
- key.data = reinterpret_cast<const char*>(&k);
- key.size = sizeof(k);
- }
-
- if (UNLIKELY(_map.find(key) != _map.end())) {
- continue;
- }
-
- key.data = _arena.insert(key.data, key.size);
-
- _map.emplace(key, _key_column->size());
- _key_column->insert_data(key.data, key.size);
- _value_column->insert(value_array[i]);
- }
- }
-
- void merge(const AggregateFunctionMapAggData& other) {
- const size_t num_rows = other._key_column->size();
- if (num_rows == 0) {
- return;
- }
-
- auto& other_key_column =
assert_cast<KeyColumnType&>(*other._key_column);
-
- for (size_t i = 0; i != num_rows; ++i) {
- auto key =
static_cast<KeyColumnType&>(other_key_column).get_data_at(i);
- if (_map.find(key) != _map.cend()) {
- continue;
- }
- key.data = _arena.insert(key.data, key.size);
-
- _map.emplace(key, _key_column->size());
- static_cast<KeyColumnType&>(*_key_column).insert_data(key.data,
key.size);
-
- auto value = other._value_column->get_data_at(i);
- _value_column->insert_data(value.data, value.size);
- }
- }
-
- void insert_result_into(IColumn& to) const {
- auto& dst = assert_cast<ColumnMap&, TypeCheckOnRelease::DISABLE>(to);
- size_t num_rows = _key_column->size();
- auto& offsets = dst.get_offsets();
- auto& dst_key_column =
- assert_cast<ColumnNullable&,
TypeCheckOnRelease::DISABLE>(dst.get_keys());
-
dst_key_column.get_null_map_data().resize_fill(dst_key_column.get_null_map_data().size()
+
- num_rows);
- dst_key_column.get_nested_column().insert_range_from(*_key_column, 0,
num_rows);
- dst.get_values().insert_range_from(*_value_column, 0, num_rows);
- if (offsets.empty()) {
- offsets.push_back(num_rows);
- } else {
- offsets.push_back(offsets.back() + num_rows);
- }
- }
-
- void write(BufferWritable& buf) const {
- const size_t size = _key_column->size();
- buf.write_binary(size);
- for (size_t i = 0; i < size; i++) {
- buf.write_binary(assert_cast<KeyColumnType&,
TypeCheckOnRelease::DISABLE>(*_key_column)
- .get_data_at(i));
- }
- for (size_t i = 0; i < size; i++) {
- buf.write_binary(_value_column->get_data_at(i));
- }
- }
-
- void read(BufferReadable& buf) {
- size_t size = 0;
- buf.read_binary(size);
- StringRef key;
- for (size_t i = 0; i < size; i++) {
- buf.read_binary(key);
- DCHECK(_map.find(key) == _map.cend());
- key.data = _arena.insert(key.data, key.size);
- assert_cast<KeyColumnType&,
TypeCheckOnRelease::DISABLE>(*_key_column)
- .insert_data(key.data, key.size);
- }
- StringRef val;
- for (size_t i = 0; i < size; i++) {
- buf.read_binary(val);
- _value_column->insert_data(val.data, val.size);
- }
- }
-
-private:
- using KeyColumnType = typename PrimitiveTypeTraits<K>::ColumnType;
- Map _map;
- Arena _arena;
- IColumn::MutablePtr _key_column;
- IColumn::MutablePtr _value_column;
- DataTypePtr _key_type;
- DataTypePtr _value_type;
-};
-
-template <typename Data, PrimitiveType K>
-class AggregateFunctionMapAgg final
- : public IAggregateFunctionDataHelper<Data,
AggregateFunctionMapAgg<Data, K>>,
- MultiExpression,
- NotNullableAggregateFunction {
-public:
- using KeyColumnType = typename PrimitiveTypeTraits<K>::ColumnType;
- AggregateFunctionMapAgg() = default;
- AggregateFunctionMapAgg(const DataTypes& argument_types_)
- : IAggregateFunctionDataHelper<Data, AggregateFunctionMapAgg<Data,
K>>(
- argument_types_) {}
-
- std::string get_name() const override { return "map_agg_v1"; }
-
- DataTypePtr get_return_type() const override {
- /// keys and values column of `ColumnMap` are always nullable.
- return std::make_shared<DataTypeMap>(make_nullable(argument_types[0]),
- make_nullable(argument_types[1]));
- }
-
- void add(AggregateDataPtr __restrict place, const IColumn** columns,
ssize_t row_num,
- Arena&) const override {
- if (const auto* nullable_col =
check_and_get_column<ColumnNullable>(columns[0])) {
- const auto& nullable_map = nullable_col->get_null_map_data();
- if (nullable_map[row_num]) {
- return;
- }
- Field value;
- columns[1]->get(row_num, value);
- this->data(place).add(assert_cast<const KeyColumnType&,
TypeCheckOnRelease::DISABLE>(
- nullable_col->get_nested_column())
- .get_data_at(row_num),
- value);
- } else {
- Field value;
- columns[1]->get(row_num, value);
- this->data(place).add(
- assert_cast<const KeyColumnType&,
TypeCheckOnRelease::DISABLE>(*columns[0])
- .get_data_at(row_num),
- value);
- }
- }
-
- void create(AggregateDataPtr __restrict place) const override {
- new (place) Data(argument_types);
- }
-
- void reset(AggregateDataPtr place) const override {
this->data(place).reset(); }
-
- void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs,
- Arena&) const override {
- this->data(place).merge(this->data(rhs));
- }
-
- void serialize(ConstAggregateDataPtr __restrict place, BufferWritable&
buf) const override {
- this->data(place).write(buf);
- }
-
- void deserialize(AggregateDataPtr __restrict place, BufferReadable& buf,
- Arena&) const override {
- this->data(place).read(buf);
- }
-
- void streaming_agg_serialize_to_column(const IColumn** columns,
MutableColumnPtr& dst,
- const size_t num_rows, Arena&)
const override {
- auto& col = assert_cast<ColumnMap&>(*dst);
- for (size_t i = 0; i != num_rows; ++i) {
- Field key, value;
- columns[0]->get(i, key);
- if (key.is_null()) {
- col.insert(Field::create_field<TYPE_MAP>(
- Map {Field::create_field<TYPE_ARRAY>(Array {}),
- Field::create_field<TYPE_ARRAY>(Array {})}));
- continue;
- }
-
- columns[1]->get(i, value);
- col.insert(Field::create_field<TYPE_MAP>(
- Map {Field::create_field<TYPE_ARRAY>(Array {key}),
- Field::create_field<TYPE_ARRAY>(Array {value})}));
- }
- }
-
- void serialize_to_column(const std::vector<AggregateDataPtr>& places,
size_t offset,
- MutableColumnPtr& dst, const size_t num_rows)
const override {
- for (size_t i = 0; i != num_rows; ++i) {
- Data& data_ = this->data(places[i] + offset);
- data_.insert_result_into(*dst);
- }
- }
-
- void deserialize_and_merge_from_column_range(AggregateDataPtr __restrict
place,
- const IColumn& column, size_t
begin, size_t end,
- Arena&) const override {
- DCHECK(end <= column.size() && begin <= end)
- << ", begin:" << begin << ", end:" << end << ",
column.size():" << column.size();
- const auto& col = assert_cast<const ColumnMap&>(column);
- for (size_t i = begin; i <= end; ++i) {
- auto map = col[i].get<TYPE_MAP>();
- this->data(place).add(map[0], map[1]);
- }
- }
-
- void deserialize_and_merge_vec(const AggregateDataPtr* places, size_t
offset,
- AggregateDataPtr rhs, const IColumn*
column, Arena&,
- const size_t num_rows) const override {
- const auto& col = assert_cast<const ColumnMap&>(*column);
- for (size_t i = 0; i != num_rows; ++i) {
- auto map = col[i].get<TYPE_MAP>();
- this->data(places[i] + offset).add(map[0], map[1]);
- }
- }
-
- void deserialize_and_merge_vec_selected(const AggregateDataPtr* places,
size_t offset,
- AggregateDataPtr rhs, const
IColumn* column, Arena&,
- const size_t num_rows) const
override {
- const auto& col = assert_cast<const ColumnMap&>(*column);
- for (size_t i = 0; i != num_rows; ++i) {
- if (places[i]) {
- auto map = col[i].get<TYPE_MAP>();
- this->data(places[i] + offset).add(map[0], map[1]);
- }
- }
- }
-
- void serialize_without_key_to_column(ConstAggregateDataPtr __restrict
place,
- IColumn& to) const override {
- this->data(place).insert_result_into(to);
- }
-
- void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn&
to) const override {
- this->data(place).insert_result_into(to);
- }
-
- void check_input_columns_type(const IColumn** columns) const override {
- IAggregateFunction::check_input_columns_type(columns);
- if constexpr (is_string_type(K)) {
- const IColumn* key_column = columns[0];
- if (const auto* nullable_column =
check_and_get_column<ColumnNullable>(*key_column)) {
- key_column = &nullable_column->get_nested_column();
- }
- this->template
check_argument_column_type<ColumnString>(key_column);
- }
- }
-
- [[nodiscard]] MutableColumnPtr create_serialize_column() const override {
- return get_return_type()->create_column();
- }
-
- [[nodiscard]] DataTypePtr get_serialized_type() const override { return
get_return_type(); }
-
-protected:
- using IAggregateFunction::argument_types;
-};
-
-} // namespace doris
diff --git a/be/src/exprs/aggregate/aggregate_function_simple_factory.cpp
b/be/src/exprs/aggregate/aggregate_function_simple_factory.cpp
index 2d1a94dc04c..e0e48cef8c4 100644
--- a/be/src/exprs/aggregate/aggregate_function_simple_factory.cpp
+++ b/be/src/exprs/aggregate/aggregate_function_simple_factory.cpp
@@ -68,7 +68,6 @@ void
register_aggregate_function_sequence_match(AggregateFunctionSimpleFactory&
void register_aggregate_function_avg_weighted(AggregateFunctionSimpleFactory&
factory);
void register_aggregate_function_histogram(AggregateFunctionSimpleFactory&
factory);
void
register_aggregate_function_linear_histogram(AggregateFunctionSimpleFactory&
factory);
-void register_aggregate_function_map_agg(AggregateFunctionSimpleFactory&
factory);
void register_aggregate_function_map_agg_v2(AggregateFunctionSimpleFactory&
factory);
void
register_aggregate_function_map_combinator(AggregateFunctionSimpleFactory&
factory);
void register_aggregate_function_bitmap_agg(AggregateFunctionSimpleFactory&
factory);
@@ -123,7 +122,6 @@ AggregateFunctionSimpleFactory&
AggregateFunctionSimpleFactory::instance() {
register_aggregate_function_avg_weighted(instance);
register_aggregate_function_histogram(instance);
register_aggregate_function_linear_histogram(instance);
- register_aggregate_function_map_agg(instance);
register_aggregate_function_map_agg_v2(instance);
register_aggregate_function_map_combinator(instance);
register_aggregate_function_bitmap_agg(instance);
diff --git a/be/test/exec/agg/agg_fn_evaluator_test.cpp
b/be/test/exec/agg/agg_fn_evaluator_test.cpp
index ad2b13b225a..940b249aa84 100644
--- a/be/test/exec/agg/agg_fn_evaluator_test.cpp
+++ b/be/test/exec/agg/agg_fn_evaluator_test.cpp
@@ -546,35 +546,6 @@ TEST(AggFnEvaluatorTest,
datasketches_hll_union_agg_check_string_input_physical_
agg_fn->destroy(place);
}
-TEST(AggFnEvaluatorTest, map_agg_check_string_key_input_physical_column_type) {
- for (bool nullable_key : {false, true}) {
- SCOPED_TRACE(nullable_key);
- ObjectPool pool;
- DataTypePtr key_type = std::make_shared<DataTypeString>();
- if (nullable_key) {
- key_type = make_nullable(key_type);
- }
- auto* agg_fn = create_agg_fn(pool, "map_agg_v1",
- {key_type,
std::make_shared<DataTypeInt64>()}, nullptr, false);
- Arena arena;
-
- MutableColumnPtr key_column =
- nullable_key ? create_nullable_string64_column() :
create_string64_column();
- Block block({ColumnWithTypeAndName(std::move(key_column), key_type,
"bad_key"),
-
ColumnWithTypeAndName(ColumnHelper::create_column<DataTypeInt64>({1, 2, 3}),
- std::make_shared<DataTypeInt64>(),
"value")});
-
- auto* place =
reinterpret_cast<AggregateDataPtr>(arena.alloc(agg_fn->size_of_data()));
- agg_fn->create(place);
-
- expect_exception_message_contains(
- [&]() { static_cast<void>(agg_fn->execute_single_add(&block,
place, arena)); },
- "argument type check failed");
-
- agg_fn->destroy(place);
- }
-}
-
TEST(AggFnEvaluatorTest, map_combinator_check_string_key_physical_column_type)
{
ObjectPool pool;
auto map_type =
std::make_shared<DataTypeMap>(make_nullable(std::make_shared<DataTypeString>()),
diff --git a/be/test/storage/rowset/segment_flusher_format_test.cpp
b/be/test/storage/rowset/segment_flusher_format_test.cpp
index 22802570fd9..5d0b139bbd7 100644
--- a/be/test/storage/rowset/segment_flusher_format_test.cpp
+++ b/be/test/storage/rowset/segment_flusher_format_test.cpp
@@ -778,7 +778,7 @@ TabletSchemaSPtr
create_complex_value_schema(TabletStorageFormatPB storage_forma
add_child_column(hll_union, 901, "arg", hll_type, false);
auto* array_agg = add_agg_state_column(10, "v_agg_array", "array_agg");
add_child_column(array_agg, 1001, "arg", kKeyTypes[3], true);
- auto* map_agg = add_agg_state_column(11, "v_agg_map", "map_agg_v1");
+ auto* map_agg = add_agg_state_column(11, "v_agg_map", "map_agg_v2");
add_child_column(map_agg, 1101, "key", kKeyTypes[12], true);
add_child_column(map_agg, 1102, "value", kKeyTypes[3], true);
auto* bitmap_union = add_agg_state_column(12, "v_agg_bitmap_union",
"bitmap_union");
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_with_variant_bloom_horizontal_compressed/segment_0.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_with_variant_bloom_horizontal_compressed/segment_0.dat
index 9334649100b..7e5fce17d26 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_with_variant_bloom_horizontal_compressed/segment_0.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_with_variant_bloom_horizontal_compressed/segment_0.dat
differ
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_with_variant_bloom_horizontal_compressed/segment_1.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_with_variant_bloom_horizontal_compressed/segment_1.dat
index b511370b985..b6d9603d749 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_with_variant_bloom_horizontal_compressed/segment_1.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_with_variant_bloom_horizontal_compressed/segment_1.dat
differ
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_without_variant_bloom_horizontal_compressed/segment_0.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_without_variant_bloom_horizontal_compressed/segment_0.dat
index 40dafd1782e..dc385012095 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_without_variant_bloom_horizontal_compressed/segment_0.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_without_variant_bloom_horizontal_compressed/segment_0.dat
differ
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_without_variant_bloom_horizontal_compressed/segment_1.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_without_variant_bloom_horizontal_compressed/segment_1.dat
index 15c3219654f..d5bfc49f8e7 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_without_variant_bloom_horizontal_compressed/segment_1.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v2_not_nullable_without_variant_bloom_horizontal_compressed/segment_1.dat
differ
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_with_variant_bloom_vertical_uncompressed/segment_0.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_with_variant_bloom_vertical_uncompressed/segment_0.dat
index af2330bb21a..2aac77babc1 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_with_variant_bloom_vertical_uncompressed/segment_0.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_with_variant_bloom_vertical_uncompressed/segment_0.dat
differ
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_with_variant_bloom_vertical_uncompressed/segment_1.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_with_variant_bloom_vertical_uncompressed/segment_1.dat
index a367def8e84..4ca8478218c 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_with_variant_bloom_vertical_uncompressed/segment_1.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_with_variant_bloom_vertical_uncompressed/segment_1.dat
differ
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_without_variant_bloom_vertical_compressed/segment_0.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_without_variant_bloom_vertical_compressed/segment_0.dat
index 5f642e43b52..a2bcbf9c6f6 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_without_variant_bloom_vertical_compressed/segment_0.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_without_variant_bloom_vertical_compressed/segment_0.dat
differ
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_without_variant_bloom_vertical_compressed/segment_1.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_without_variant_bloom_vertical_compressed/segment_1.dat
index f282bcec210..60a3d754fda 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_without_variant_bloom_vertical_compressed/segment_1.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v2_nullable_without_variant_bloom_vertical_compressed/segment_1.dat
differ
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_with_variant_bloom_vertical_compressed/segment_0.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_with_variant_bloom_vertical_compressed/segment_0.dat
index 9a656d49a33..cf870d36a45 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_with_variant_bloom_vertical_compressed/segment_0.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_with_variant_bloom_vertical_compressed/segment_0.dat
differ
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_with_variant_bloom_vertical_compressed/segment_1.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_with_variant_bloom_vertical_compressed/segment_1.dat
index bbedb071ad1..0c70bedef55 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_with_variant_bloom_vertical_compressed/segment_1.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_with_variant_bloom_vertical_compressed/segment_1.dat
differ
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_without_variant_bloom_vertical_uncompressed/segment_0.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_without_variant_bloom_vertical_uncompressed/segment_0.dat
index 5f1aac51d1a..c92c2d9d7cb 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_without_variant_bloom_vertical_uncompressed/segment_0.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_without_variant_bloom_vertical_uncompressed/segment_0.dat
differ
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_without_variant_bloom_vertical_uncompressed/segment_1.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_without_variant_bloom_vertical_uncompressed/segment_1.dat
index 3f9bd0285d1..45607d468cc 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_without_variant_bloom_vertical_uncompressed/segment_1.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v3_not_nullable_without_variant_bloom_vertical_uncompressed/segment_1.dat
differ
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_with_variant_bloom_horizontal_compressed/segment_0.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_with_variant_bloom_horizontal_compressed/segment_0.dat
index 3d43688fd73..38b7998ace2 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_with_variant_bloom_horizontal_compressed/segment_0.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_with_variant_bloom_horizontal_compressed/segment_0.dat
differ
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_with_variant_bloom_horizontal_compressed/segment_1.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_with_variant_bloom_horizontal_compressed/segment_1.dat
index d50910fcadd..bd262d787f1 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_with_variant_bloom_horizontal_compressed/segment_1.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_with_variant_bloom_horizontal_compressed/segment_1.dat
differ
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_without_variant_bloom_horizontal_compressed/segment_0.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_without_variant_bloom_horizontal_compressed/segment_0.dat
index 9c108655b45..148bfe5a0fb 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_without_variant_bloom_horizontal_compressed/segment_0.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_without_variant_bloom_horizontal_compressed/segment_0.dat
differ
diff --git
a/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_without_variant_bloom_horizontal_compressed/segment_1.dat
b/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_without_variant_bloom_horizontal_compressed/segment_1.dat
index 206628714b2..ffe02c1030f 100644
Binary files
a/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_without_variant_bloom_horizontal_compressed/segment_1.dat
and
b/be/test/storage/test_data/segment_flusher_format/complex_v3_nullable_without_variant_bloom_horizontal_compressed/segment_1.dat
differ
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java
index 7f3fa4cddec..e20a45baf03 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinAggregateFunctions.java
@@ -55,7 +55,6 @@ import
org.apache.doris.nereids.trees.expressions.functions.agg.HllUnionAgg;
import org.apache.doris.nereids.trees.expressions.functions.agg.IntersectCount;
import org.apache.doris.nereids.trees.expressions.functions.agg.Kurt;
import
org.apache.doris.nereids.trees.expressions.functions.agg.LinearHistogram;
-import org.apache.doris.nereids.trees.expressions.functions.agg.MapAgg;
import org.apache.doris.nereids.trees.expressions.functions.agg.MapAggV2;
import org.apache.doris.nereids.trees.expressions.functions.agg.Max;
import org.apache.doris.nereids.trees.expressions.functions.agg.MaxBy;
@@ -169,7 +168,6 @@ public class BuiltinAggregateFunctions implements
FunctionHelper {
agg(IntersectCount.class, "intersect_count"),
agg(Kurt.class, "kurt", "kurt_pop", "kurtosis"),
agg(LinearHistogram.class, "linear_histogram"),
- agg(MapAgg.class, "map_agg_v1"),
agg(MapAggV2.class, "map_agg_v2", "map_agg"),
agg(Max.class, "max"),
agg(MaxBy.class, "max_by"),
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MapAgg.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MapAgg.java
deleted file mode 100644
index 393adea6d0e..00000000000
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/agg/MapAgg.java
+++ /dev/null
@@ -1,83 +0,0 @@
-// 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.
-
-package org.apache.doris.nereids.trees.expressions.functions.agg;
-
-import org.apache.doris.catalog.FunctionSignature;
-import org.apache.doris.nereids.trees.expressions.Expression;
-import
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
-import org.apache.doris.nereids.trees.expressions.literal.MapLiteral;
-import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
-import org.apache.doris.nereids.types.MapType;
-import org.apache.doris.nereids.types.coercion.AnyDataType;
-import org.apache.doris.nereids.types.coercion.FollowToAnyDataType;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-
-import java.util.LinkedHashMap;
-import java.util.List;
-
-/**
- * AggregateFunction 'map_agg'. This class is generated by GenerateFunction.
- */
-public class MapAgg extends NotNullableAggregateFunction
- implements BinaryExpression, ExplicitlyCastableSignature {
-
- public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
- FunctionSignature.ret(MapType.of(new FollowToAnyDataType(0), new
FollowToAnyDataType(1)))
- .args(new AnyDataType(0), new AnyDataType(1))
- );
-
- /**FunctionSignature
- * constructor with 2 arguments.
- */
- public MapAgg(Expression arg0, Expression arg1) {
- this(false, arg0, arg1);
- }
-
- /**
- * constructor with 2 arguments.
- */
- public MapAgg(boolean distinct, Expression arg0, Expression arg1) {
- super("map_agg_v1", distinct, arg0, arg1);
- }
-
- /** constructor for withChildren and reuse signature */
- private MapAgg(AggregateFunctionParams functionParams) {
- super(functionParams);
- }
-
- /**
- * withDistinctAndChildren.
- */
- @Override
- public MapAgg withDistinctAndChildren(boolean distinct, List<Expression>
children) {
- Preconditions.checkArgument(children.size() == 2);
- return new MapAgg(getFunctionParams(distinct, children));
- }
-
- @Override
- public List<FunctionSignature> getSignatures() {
- return SIGNATURES;
- }
-
- @Override
- public Expression resultForEmptyInput() {
- return new MapLiteral(new LinkedHashMap<>(), this.getDataType());
- }
-}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java
index 8e0151b6bdf..5a77fdf9d7a 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/AggregateFunctionVisitor.java
@@ -54,7 +54,6 @@ import
org.apache.doris.nereids.trees.expressions.functions.agg.HllUnionAgg;
import org.apache.doris.nereids.trees.expressions.functions.agg.IntersectCount;
import org.apache.doris.nereids.trees.expressions.functions.agg.Kurt;
import
org.apache.doris.nereids.trees.expressions.functions.agg.LinearHistogram;
-import org.apache.doris.nereids.trees.expressions.functions.agg.MapAgg;
import org.apache.doris.nereids.trees.expressions.functions.agg.Max;
import org.apache.doris.nereids.trees.expressions.functions.agg.MaxBy;
import org.apache.doris.nereids.trees.expressions.functions.agg.Median;
@@ -277,10 +276,6 @@ public interface AggregateFunctionVisitor<R, C> {
return visitNullableAggregateFunction(aiAgg, context);
}
- default R visitMapAgg(MapAgg mapAgg, C context) {
- return visitAggregateFunction(mapAgg, context);
- }
-
default R visitMax(Max max, C context) {
return visitNullableAggregateFunction(max, context);
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/InferAggNotNullTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/InferAggNotNullTest.java
index 07ced8248ed..eee7c008631 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/InferAggNotNullTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/InferAggNotNullTest.java
@@ -36,7 +36,6 @@ import
org.apache.doris.nereids.trees.expressions.functions.agg.Count;
import org.apache.doris.nereids.trees.expressions.functions.agg.CountByEnum;
import
org.apache.doris.nereids.trees.expressions.functions.agg.DataSketchesHllUnionAgg;
import org.apache.doris.nereids.trees.expressions.functions.agg.GroupConcat;
-import org.apache.doris.nereids.trees.expressions.functions.agg.MapAgg;
import org.apache.doris.nereids.trees.expressions.functions.agg.MapAggV2;
import org.apache.doris.nereids.trees.expressions.functions.agg.Max;
import org.apache.doris.nereids.trees.expressions.functions.agg.Min;
@@ -179,7 +178,6 @@ class InferAggNotNullTest implements
MemoPatternMatchSupported {
// NotNullableAggregateFunction does not imply that NULL argument rows
can be removed.
List<AggregateFunction> withoutClassWideProof = ImmutableList.of(
new ArrayAgg(value),
- new MapAgg(key, value),
new MapAggV2(key, value),
new CountByEnum(value),
new GroupConcat(value));
diff --git a/regression-test/data/query_p0/aggregate/map_agg_v1.out
b/regression-test/data/query_p0/aggregate/map_agg_v1.out
deleted file mode 100644
index 6860ccf87c7..00000000000
--- a/regression-test/data/query_p0/aggregate/map_agg_v1.out
+++ /dev/null
@@ -1,50 +0,0 @@
--- This file is automatically generated. You should know what you did if you
want to edit this
--- !sql1 --
-1 V1_1 V1_2 V1_3
-2 V2_1 V2_2 V2_3
-3 V3_1 V3_2 V3_3
-4 V4_1 V4_2 V4_3
-5 V5_1 V5_2 V5_3
-
--- !sql2 --
-1 V1_1 V1_2 \N
-2 V2_1 \N V2_3
-3 V3_1 V3_2 V3_3
-4 V4_1 V4_2 \N
-5 V5_1 V5_2 V5_3
-
--- !sql3 --
-1 V1_1 V1_2 V1_3
-2 V2_1 V2_2 V2_3
-3 V3_1 V3_2 V3_3
-4 V4_1 V4_2 V4_3
-5 V5_1 V5_2 V5_3
-
--- !sql4 --
-{"key":["ab", "efg", null]}
-
--- !sql5 --
-1 1.2345 2.4567 5.9876
-2 2.4567 3.3300 4.5500
-3 188.9980 998.9960 1024.1024
-
--- !sql6 --
-\N
-\N
-V2_3
-V3_3
-V5_3
-
--- !garbled_characters --
-001 90 92 80 \N
-002 88 90 75.5 \N
-003 70 85 90 82
-
--- !multi --
-1 2
-
--- !test_dumplicate --
-1 \N
-2 bddd
-3 \N
-
diff --git a/regression-test/suites/query_p0/aggregate/map_agg.groovy
b/regression-test/suites/query_p0/aggregate/map_agg.groovy
index 161d500d1d0..e76919582ce 100644
--- a/regression-test/suites/query_p0/aggregate/map_agg.groovy
+++ b/regression-test/suites/query_p0/aggregate/map_agg.groovy
@@ -405,4 +405,9 @@ suite("map_agg") {
group by k1
) a order by k1;
"""
- }
+
+ test {
+ sql "select map_agg_v1(`v1`, `v3`) from `test_map_agg_datetime`"
+ exception "Can not found function 'map_agg_v1'"
+ }
+}
diff --git a/regression-test/suites/query_p0/aggregate/map_agg_v1.groovy
b/regression-test/suites/query_p0/aggregate/map_agg_v1.groovy
deleted file mode 100644
index f8e4db519d3..00000000000
--- a/regression-test/suites/query_p0/aggregate/map_agg_v1.groovy
+++ /dev/null
@@ -1,352 +0,0 @@
-// 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.
-
-suite("map_agg_v1") {
- sql "DROP TABLE IF EXISTS `test_map_agg_v1`;"
- sql """
- CREATE TABLE IF NOT EXISTS `test_map_agg_v1` (
- `id` int(11) NOT NULL,
- `label_name` varchar(32) NOT NULL,
- `value_field` string
- ) ENGINE=OLAP
- DUPLICATE KEY(`id`)
- COMMENT 'OLAP'
- DISTRIBUTED BY HASH(`id`) BUCKETS 2
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "storage_format" = "V2",
- "light_schema_change" = "true",
- "disable_auto_compaction" = "false"
- );
- """
-
- sql """
- insert into `test_map_agg_v1` values
- (1, "LA", "V1_1"),
- (1, "LB", "V1_2"),
- (1, "LC", "V1_3"),
- (2, "LA", "V2_1"),
- (2, "LB", "V2_2"),
- (2, "LC", "V2_3"),
- (3, "LA", "V3_1"),
- (3, "LB", "V3_2"),
- (3, "LC", "V3_3"),
- (4, "LA", "V4_1"),
- (4, "LB", "V4_2"),
- (4, "LC", "V4_3"),
- (5, "LA", "V5_1"),
- (5, "LB", "V5_2"),
- (5, "LC", "V5_3");
- """
-
- sql "DROP TABLE IF EXISTS test_map_agg_v1_nullable;"
- sql """
- CREATE TABLE IF NOT EXISTS `test_map_agg_v1_nullable` (
- `id` int(11) NOT NULL,
- `label_name` varchar(32) NULL,
- `value_field` string
- ) ENGINE=OLAP
- DUPLICATE KEY(`id`)
- COMMENT 'OLAP'
- DISTRIBUTED BY HASH(`id`) BUCKETS 10
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "storage_format" = "V2",
- "light_schema_change" = "true",
- "disable_auto_compaction" = "false"
- );
- """
- sql """
- insert into `test_map_agg_v1_nullable` values
- (1, "LA", "V1_1"),
- (1, "LB", "V1_2"),
- (1, "LC", null),
- (2, "LA", "V2_1"),
- (2, null, "V2_2"),
- (2, "LC", "V2_3"),
- (3, "LA", "V3_1"),
- (3, "LB", "V3_2"),
- (3, "LC", "V3_3"),
- (4, "LA", "V4_1"),
- (4, "LB", "V4_2"),
- (4, null, null),
- (5, "LA", "V5_1"),
- (5, "LB", "V5_2"),
- (5, "LC", "V5_3");
- """
-
- sql "DROP TABLE IF EXISTS `test_map_agg_v1_numeric_key`;"
- sql """
- CREATE TABLE IF NOT EXISTS `test_map_agg_v1_numeric_key` (
- `id` int(11) NOT NULL,
- `label_name` bigint NOT NULL,
- `value_field` string
- ) ENGINE=OLAP
- DUPLICATE KEY(`id`)
- COMMENT 'OLAP'
- DISTRIBUTED BY HASH(`id`) BUCKETS 2
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "storage_format" = "V2",
- "light_schema_change" = "true",
- "disable_auto_compaction" = "false"
- );
- """
-
- sql """
- insert into `test_map_agg_v1_numeric_key` values
- (1, 1, "V1_1"),
- (1, 9223372036854775807, "V1_2"),
- (1, 22000000000, "V1_3"),
- (2, 1, "V2_1"),
- (2, 9223372036854775807, "V2_2"),
- (2, 22000000000, "V2_3"),
- (3, 1, "V3_1"),
- (3, 9223372036854775807, "V3_2"),
- (3, 22000000000, "V3_3"),
- (4, 1, "V4_1"),
- (4, 9223372036854775807, "V4_2"),
- (4, 22000000000, "V4_3"),
- (5, 1, "V5_1"),
- (5, 9223372036854775807, "V5_2"),
- (5, 22000000000, "V5_3");
- """
-
- sql "DROP TABLE IF EXISTS `test_map_agg_v1_decimal`;"
- sql """
- CREATE TABLE IF NOT EXISTS `test_map_agg_v1_decimal` (
- `id` int(11) NOT NULL,
- `label_name` string NOT NULL,
- `value_field` decimal(15,4)
- ) ENGINE=OLAP
- DUPLICATE KEY(`id`)
- COMMENT 'OLAP'
- DISTRIBUTED BY HASH(`id`) BUCKETS 2
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "storage_format" = "V2",
- "light_schema_change" = "true",
- "disable_auto_compaction" = "false"
- );
- """
-
- sql """
- insert into `test_map_agg_v1_decimal` values
- (1, "k1", 1.2345),
- (1, "k2", 2.4567),
- (1, "k3", 5.9876),
- (2, "k1", 2.4567),
- (2, "k2", 3.33),
- (2, "k3", 4.55),
- (3, "k1", 188.998),
- (3, "k2", 998.996),
- (3, "k3", 1024.1024)
- """
-
- sql "DROP TABLE IF EXISTS `test_map_agg_v1_score`;"
- sql """
- CREATE TABLE `test_map_agg_v1_score`(
- id INT(11) NOT NULL,
- userid VARCHAR(20) NOT NULL COMMENT '用户id',
- subject VARCHAR(20) COMMENT '科目',
- score DOUBLE COMMENT '成绩'
- )
- DUPLICATE KEY(`id`)
- COMMENT 'OLAP'
- DISTRIBUTED BY HASH(`id`) BUCKETS 1
- PROPERTIES (
- "replication_allocation" = "tag.location.default: 1",
- "in_memory" = "false",
- "storage_format" = "V2",
- "light_schema_change" = "true",
- "disable_auto_compaction" = "false"
- );
- """
-
- sql """
- INSERT INTO `test_map_agg_v1_score` VALUES (1,'001','语文',90);
- """
- sql """
- INSERT INTO `test_map_agg_v1_score` VALUES (2,'001','数学',92);
- """
- sql """
- INSERT INTO `test_map_agg_v1_score` VALUES (3,'001','英语',80);
- """
- sql """
- INSERT INTO `test_map_agg_v1_score` VALUES (4,'002','语文',88);
- """
- sql """
- INSERT INTO `test_map_agg_v1_score` VALUES (5,'002','数学',90);
- """
- sql """
- INSERT INTO `test_map_agg_v1_score` VALUES (6,'002','英语',75.5);
- """
- sql """
- INSERT INTO `test_map_agg_v1_score` VALUES (7,'003','语文',70);
- """
- sql """
- INSERT INTO `test_map_agg_v1_score` VALUES (8,'003','数学',85);
- """
- sql """
- INSERT INTO `test_map_agg_v1_score` VALUES (9,'003','英语',90);
- """
- sql """
- INSERT INTO `test_map_agg_v1_score` VALUES (10,'003','政治',82);
- """
-
- qt_sql1 """
- WITH `labels` as (
- SELECT `id`, map_agg_v1(`label_name`, `value_field`) m FROM
test_map_agg_v1 GROUP BY `id`
- )
- SELECT
- id,
- m['LA'] LA,
- m['LB'] LB,
- m['LC'] LC
- FROM `labels`
- ORDER BY `id`;
- """
-
- qt_sql2 """
- WITH `labels` as (
- SELECT `id`, map_agg_v1(`label_name`, `value_field`) m FROM
test_map_agg_v1_nullable GROUP BY `id`
- )
- SELECT
- id,
- m['LA'] LA,
- m['LB'] LB,
- m['LC'] LC
- FROM `labels`
- ORDER BY `id`;
- """
-
- qt_sql3 """
- WITH `labels` as (
- SELECT `id`, map_agg_v1(`label_name`, `value_field`) m FROM
test_map_agg_v1_numeric_key GROUP BY `id`
- )
- SELECT
- id,
- m[1] LA,
- m[9223372036854775807] LB,
- m[22000000000] LC
- FROM `labels`
- ORDER BY `id`;
- """
-
- qt_sql4 """
- select map_agg_v1(k, v) from (select 'key' as k, array('ab', 'efg',
null) v) a;
- """
-
- qt_sql5 """
- WITH `labels` as (
- SELECT `id`, map_agg_v1(`label_name`, `value_field`) m FROM
test_map_agg_v1_decimal GROUP BY `id`
- )
- SELECT
- id,
- m["k1"] LA,
- m["k2"] LB,
- m["k3"] LC
- FROM `labels`
- ORDER BY `id`;
- """
-
- qt_sql6 """
- select m['LC'] from (SELECT `id`, map_agg_v1(`label_name`,
`value_field`) m FROM test_map_agg_v1_nullable GROUP BY `id`)t order by 1;
- """
-
- qt_garbled_characters """
- select
- userid, map['语文'] 语文, map['数学'] 数学, map['英语'] 英语, map['政治'] 政治
- from (
- select userid, map_agg_v1(subject,score) as map from
test_map_agg_v1_score group by userid
- ) a order by userid;
- """
-
- sql "DROP TABLE IF EXISTS test_map_agg_v1_multi;"
- sql """
- create table test_map_agg_v1_multi (
- data_time bigint,
- mil int,
- vin string,
- car_type string,
- month string,
- day string
- ) engine=olap
- distributed by hash(data_time) buckets 10
- properties("replication_num" = "1");
- """
- sql """
- insert into test_map_agg_v1_multi values (1, 1, 'abc', 'bc', '01',
'01'), (2, 2, 'abc', 'bc', '01', '01');
- """
-
- qt_multi """
- select
- m1['1']
- , m2['2']
- from (
- select
- vin
- , car_type
- , map_agg_v1(ts, mile) m1
- , map_agg_v1(mile, ts) m2
- from (
- select
- vin
- , car_type
- , data_time as ts
- , mil as mile, month
- , day from test_map_agg_v1_multi
- )a
- group by
- car_type
- , vin
- , month
- , day
- ) t order by 1, 2;
- """
-
- sql "DROP TABLE IF EXISTS `test_map_agg_v1_2`;"
- sql """
- CREATE TABLE `test_map_agg_v1_2` (
- `k1` int NULL,
- `k2` int NULL,
- `v1` text NULL,
- `v2` text NULL
- ) ENGINE=OLAP
- DUPLICATE KEY(`k1`, `k2`)
- DISTRIBUTED BY HASH(`k1`) BUCKETS 4
- PROPERTIES ( 'replication_num' = '1');
- """
-
- sql """
- insert into `test_map_agg_v1_2` values
- ( 3 , 1 , 'k' , 'j' ),
- ( 3 , 2 , 'a' , 'a3' ),
- ( 5 , 2 , 'a' , 'a5' ),
- ( 1 , 1 , 'ee' , 'nn' ),
- ( 1 , 1 , 'a' , 'b' ),
- ( 1 , 2 , 'a' , 'b' ),
- ( 1 , 3 , 'c' , 'c' ),
- ( 2 , 1 , 'e' , 'f' ),
- ( 2 , 2 , 'a' , 'a2' ),
- ( 4 , 2 , 'b' , 'bddd' ),
- ( 4 , 2 , 'a' , 'a4' );
- """
-
- sql "set experimental_ignore_storage_data_distribution = 0;"
- qt_test_dumplicate "select k2, m['b'] from (select k2, map_agg_v1(v1, v2)
m from `test_map_agg_v1_2` group by k2) a order by k2;"
- }
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]