mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-22 17:50:47 +00:00
dbms: fixed Limits for DISTINCT [#CONV-7934].
This commit is contained in:
parent
fb616fd5ca
commit
acad879df8
@ -13,8 +13,6 @@ namespace DB
|
||||
* Для реализации SELECT DISTINCT ... .
|
||||
* Если указан ненулевой limit - прекращает выдавать строки после того, как накопилось limit строк
|
||||
* - для оптимизации SELECT DISTINCT ... LIMIT ... .
|
||||
*
|
||||
* TODO: Ограничение на максимальное количество строк в множестве.
|
||||
*/
|
||||
class DistinctBlockInputStream : public IProfilingBlockInputStream
|
||||
{
|
||||
@ -94,22 +92,6 @@ protected:
|
||||
/// Если вставилось в множество - строчку оставляем, иначе - удаляем.
|
||||
filter[i] = set.insert(key).second;
|
||||
|
||||
if (!checkLimits())
|
||||
{
|
||||
if (overflow_mode == Limits::THROW)
|
||||
throw Exception("DISTINCT-Set size limit exceeded."
|
||||
" Rows: " + Poco::NumberFormatter::format(set.size()) +
|
||||
", limit: " + Poco::NumberFormatter::format(max_rows) +
|
||||
". Bytes: " + Poco::NumberFormatter::format(set.getBufferSizeInBytes()) +
|
||||
", limit: " + Poco::NumberFormatter::format(max_bytes) + ".",
|
||||
ErrorCodes::SET_SIZE_LIMIT_EXCEEDED);
|
||||
|
||||
if (overflow_mode == Limits::BREAK)
|
||||
break;
|
||||
|
||||
throw Exception("Logical error: unknown overflow mode", ErrorCodes::LOGICAL_ERROR);
|
||||
}
|
||||
|
||||
if (limit && set.size() == limit)
|
||||
break;
|
||||
}
|
||||
@ -118,6 +100,22 @@ protected:
|
||||
if (set.size() == old_set_size)
|
||||
continue;
|
||||
|
||||
if (!checkLimits())
|
||||
{
|
||||
if (overflow_mode == Limits::THROW)
|
||||
throw Exception("DISTINCT-Set size limit exceeded."
|
||||
" Rows: " + Poco::NumberFormatter::format(set.size()) +
|
||||
", limit: " + Poco::NumberFormatter::format(max_rows) +
|
||||
". Bytes: " + Poco::NumberFormatter::format(set.getBufferSizeInBytes()) +
|
||||
", limit: " + Poco::NumberFormatter::format(max_bytes) + ".",
|
||||
ErrorCodes::SET_SIZE_LIMIT_EXCEEDED);
|
||||
|
||||
if (overflow_mode == Limits::BREAK)
|
||||
return Block();
|
||||
|
||||
throw Exception("Logical error: unknown overflow mode", ErrorCodes::LOGICAL_ERROR);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < columns; ++i)
|
||||
block.getByPosition(i).column = block.getByPosition(i).column->filter(filter);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user