Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions be/src/vec/aggregate_functions/aggregate_function_group_concat.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct AggregateFunctionGroupConcatData {
}

std::string get() const { return data; }
bool is_null() const { return !inited; }

void write(BufferWritable& buf) const {
write_binary(data, buf);
Expand Down Expand Up @@ -132,8 +133,15 @@ class AggregateFunctionGroupConcat final
}

void insert_result_into(ConstAggregateDataPtr __restrict place, IColumn& to) const override {
std::string result = this->data(place).get();
static_cast<ColumnString&>(to).insert_data(result.c_str(), result.length());
bool is_null = this->data(place).is_null();
std::string result = is_null ? "" : this->data(place).get();
if (to.is_nullable()) {
static_cast<ColumnNullable&>(to).get_null_map_data().push_back(is_null);
static_cast<ColumnNullable&>(to).get_nested_column().insert_data(result.c_str(),
result.length());
} else {
static_cast<ColumnString&>(to).insert_data(result.c_str(), result.length());
}
}
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
1 \N

-- !select --
1 \N

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// 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("test_group_concat_new_tbl", "issue_7288") {
def leftTableName = "group_concat_i7288_left"
def rightTableName = "group_concat_i7288_right"
sql "DROP TABLE IF EXISTS ${leftTableName}"
sql """
CREATE TABLE IF NOT EXISTS ${leftTableName} (
k1 int,
no varchar(10) NOT NULL
)
DISTRIBUTED BY HASH(k1) BUCKETS 1
PROPERTIES (
"replication_num" = "1"
)
"""
sql "INSERT INTO ${leftTableName} values(1,'test')"

sql "DROP TABLE IF EXISTS ${rightTableName}"
sql """
CREATE TABLE IF NOT EXISTS ${rightTableName} (
k1 int,
no varchar(10) NOT NULL
)
DISTRIBUTED BY HASH(k1) BUCKETS 1
PROPERTIES (
"replication_num" = "1"
)
"""

sql "set enable_vectorized_engine=true"
qt_select(""" select l.k1, group_concat(r.no) from ${leftTableName} l left join ${rightTableName} r on l.k1=r.k1 group by l.k1; """);

sql "set enable_vectorized_engine=false"
qt_select(""" select l.k1, group_concat(r.no) from ${leftTableName} l left join ${rightTableName} r on l.k1=r.k1 group by l.k1; """);
}