ByConity / ByConity

ByConity is an open source cloud data warehouse
https://byconity.github.io/
Apache License 2.0
2.24k stars 332 forks source link

ByConity fail to execute groupArray sql and throw exception "Too large array size" #1926

Open zhaojintaozhao opened 2 weeks ago

zhaojintaozhao commented 2 weeks ago

Hi all ByConity fail to execute groupArray sql if the size of Array is more than 50 million rows. It works well if the size of Array just 1million rows. version: 1.0.0 This is my failed group array sql:

SELECT  arrayMap(x-> bitmapCardinality(x),back_bit_arr),back_dts_arr FROM
(       SELECT groupArray(bit) AS back_bit_arr,groupArray(date) AS back_dts_arr 
        FROM
        (
            SELECT  groupBitmapState(key) AS bit,toUInt32(toDate(pt_d)) AS date
            FROM db.test1 WHERE toYYYYMMDD(pt_d) between 20200101 and 20200107
            GROUP BY pt_d
        )temp
)t1

There are more than 50 million rows in db.test1 This is exception stack trace:

2024.11.09 19:05:57.770633 [ 2902952 ] (${query_uuid}} (...) <Error> TCPHandler[641] : Code: 128, e. displayText() = DB::Exception: Too large array size SOLSTATE: 54000, Stack trace:
0. Poco::Exception::Exception(std::_1::basic_string<char, std::_1::char_traits<char>, std::_1::allocato r<char> > const&, int) @ 0x11.... in /opt/byconity/clickhouse-server/bin/clickhouse
1. DB::Exception::Exception (std::_1::basic_string<char, std::_1::char_traits<char>,  std::_1::allocator<char> > const&, int, bool) @ 0x11.... in /opt/byconity/clickhouse-server/bin/clickhouse
2. DB::GroupArrayNodeBase<DB::GroupArrayNodeGeneral>::read (DB::ReadBuffer&, DB::Arena*) @ 0x11.... in /opt/byconity/clickhouse-server/bin/clickhouse
3. DB::GroupArrayGeneralImpl<DB::GroupArrayNodeGeneral, DB::GroupArrayTrait<false, false, (DB::Sampler)0> >::deserialize(char*, DB::ReadBuffer&, DB::Arena*) const @ 0x11.... in /opt/byconity/clickhouse-server/bin/clickhouse
4. DB::SerializationAggregateFunction::deserializeBinaryBulk(DB::IColumn&, DB::ReadBuffer&, unsigned long, double, bool) const @ 0x11.... in /opt/byconity/clickhouse-server/bin/clickhouse
5. DB::ISerialization::deserializeBinaryBulkWithMultipleStreams(COW<DB::IColumn>::immutable_ptr<DB::IColumn>&, unsigned long, DB::ISerialization::DeserializeBinaryBulkSettings&, std::_1::shared_ptr<DB::ISerialization::DeserializeBinaryBulkState>& , std::1::unordered_map<std::1::basic_string<char, std::__1::char_traits<char> , std::_  —1::allocator<char> >, COW<DB::IColumn>immutable_ ptr<DB::I Column>, std::1::hash<std::_1::basic_string<char, std::_1::char_traits<char> . std::_1::allocator<char> > , - std::1::egual to<std::1::basic_string<char,  std::char_traits<char>, std::.::allocator <char> > > std::L::allocator<std::1::pair<std::1::basic string<char.   std::   1::char. traits<char>, • std::1::allocator<char> > const, COW<DB: IColumn>::immut able_ptr<DB::IColumn> > >*) const @ 0x11... in /opt/byconity/clickhouse-server/bin/clickhouse
6. DB::NativeChunkInputStream::readData (DB::IDataType const&, COW<DB::IColumn>::immutable_ptr<DB::IColumn>&, DB::ReadBuffer&, unsigned long, double) @ 0x11.... in /opt/byconity/clickhouse-server/bin/clickhouse
7. DB::NativeChunkInputStream::readImpl() @ 0x11.... in /opt/byconity/clickhouse-server/bin/clickhouse
8. DB::DeserializeBu fTransform::transform (DB::Chunk&) @ 0x11.... in /opt/byconity/clickhouse-server/bin/clickhouse
9. DB::ISimpleTransform::transform (DB::Chunk&, DB::Chunk&) @ 0x11.... in /opt/byconity/clickhouse-server/bin/clickhouse
10. DB::ISimpleTrans form::work() @ 0x11.... in /opt/byconity/clickhouse-server/bin/clickhouse
11. ? @ 0x11... in /opt/byconity/clickhouse-server/bin/clickhouse
12. DB::PipelineExecutor::executestepImpl (unsigned long, unsigned long, std::_1::atomic<bool>*) @ 0x11.... in /opt/byconity/clickhouse-server/bin/clickhouse
13. DB::PipelineExecutor::executeSingleThread (unsigned long, unsigned long) @ 0x11....  in /opt/byconity/clickhouse-server/bin/clickhouse
14. ? @ 0x11... in /opt/byconity/clickhouse-server/bin/clickhouse
15. ThreadPoolImpl<std::__1::thread>::worker (std::__1::__list_iterator<std::__1::thread, void*>) 
16. @ 0x11.. in /opt/byconity/clickhouse-server/bin/clickhouse
17. @ 0x11..7 in /opt/byconity/clickhouse-server/bin/clickhouse
18. .....

Does any one face the same problem?

xuhaitao23 commented 1 week ago

我测试了一下没能复现这个问题,可以开启'print_graphviz=1'然后再执行这个查询,会在/tmp/plan下生成执行计划,可以提供一下我再看看