mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Add server setting group_array_limit_size.
This commit is contained in:
parent
35d96f98f4
commit
6098f98cf4
@ -753,13 +753,21 @@ size_t getMaxArraySize()
|
||||
return 0xFFFFFF;
|
||||
}
|
||||
|
||||
bool isLimitArraySize()
|
||||
{
|
||||
if (auto context = Context::getGlobalContextInstance())
|
||||
return context->getServerSettings().aggregate_function_group_array_limit_size;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <bool Tlast>
|
||||
AggregateFunctionPtr createAggregateFunctionGroupArray(
|
||||
const std::string & name, const DataTypes & argument_types, const Array & parameters, const Settings *)
|
||||
{
|
||||
assertUnary(name, argument_types);
|
||||
|
||||
bool limit_size = false;
|
||||
bool limit_size = isLimitArraySize();
|
||||
UInt64 max_elems = getMaxArraySize();
|
||||
|
||||
if (parameters.empty())
|
||||
|
@ -50,6 +50,7 @@ namespace DB
|
||||
M(UInt64, max_temporary_data_on_disk_size, 0, "The maximum amount of storage that could be used for external aggregation, joins or sorting., ", 0) \
|
||||
M(String, temporary_data_in_cache, "", "Cache disk name for temporary data.", 0) \
|
||||
M(UInt64, aggregate_function_group_array_max_element_size, 0xFFFFFF, "Max array element size in bytes for groupArray function. This limit is checked at serialization and help to avoid large state size.", 0) \
|
||||
M(Bool, aggregate_function_group_array_limit_size, false, "This is set to true. Array elements are truncated when they exceed the max array element size.", 0) \
|
||||
M(UInt64, max_server_memory_usage, 0, "Maximum total memory usage of the server in bytes. Zero means unlimited.", 0) \
|
||||
M(Double, max_server_memory_usage_to_ram_ratio, 0.9, "Same as max_server_memory_usage but in to RAM ratio. Allows to lower max memory on low-memory systems.", 0) \
|
||||
M(UInt64, merges_mutations_memory_usage_soft_limit, 0, "Maximum total memory usage for merges and mutations in bytes. Zero means unlimited.", 0) \
|
||||
|
@ -1,3 +1,4 @@
|
||||
<clickhouse>
|
||||
<aggregate_function_group_array_max_element_size>10</aggregate_function_group_array_max_element_size>
|
||||
<aggregate_function_group_array_limit_size>false</aggregate_function_group_array_limit_size>
|
||||
</clickhouse>
|
||||
|
@ -63,3 +63,32 @@ def test_max_exement_size(started_cluster):
|
||||
node1.restart_clickhouse()
|
||||
|
||||
assert node1.query("select length(groupArrayMerge(x)) from tab3") == "21\n"
|
||||
|
||||
def test_limit_size(started_cluster):
|
||||
node1.query(
|
||||
"CREATE TABLE tab4 (x AggregateFunction(groupArray, Array(UInt8))) ENGINE = MergeTree ORDER BY tuple()"
|
||||
)
|
||||
node1.query("insert into tab4 select groupArrayState([zero]) from zeros(10)")
|
||||
assert node1.query("select length(groupArrayMerge(x)) from tab4") == "10\n"
|
||||
|
||||
node1.replace_in_config(
|
||||
"/etc/clickhouse-server/config.d/group_array_max_element_size.xml",
|
||||
"false",
|
||||
"true",
|
||||
)
|
||||
|
||||
node1.restart_clickhouse()
|
||||
|
||||
node1.query("insert into tab4 select groupArrayState([zero]) from zeros(100)")
|
||||
assert node1.query("select length(groupArrayMerge(x)) from tab4") == "10\n"
|
||||
|
||||
node1.replace_in_config(
|
||||
"/etc/clickhouse-server/config.d/group_array_max_element_size.xml",
|
||||
"true",
|
||||
"false",
|
||||
)
|
||||
|
||||
node1.restart_clickhouse()
|
||||
|
||||
with pytest.raises(Exception, match=r"Too large array size"):
|
||||
node1.query("insert into tab4 select groupArrayState([zero]) from zeros(11)")
|
||||
|
Loading…
Reference in New Issue
Block a user