mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
fix sorting of sparse columns with large limit
This commit is contained in:
parent
891ae75c55
commit
8447a93931
@ -1,3 +1,4 @@
|
||||
#include "Common/typeid_cast.h"
|
||||
#include <Columns/ColumnSparse.h>
|
||||
#include <Columns/ColumnsCommon.h>
|
||||
#include <Columns/ColumnCompressed.h>
|
||||
@ -439,7 +440,7 @@ void ColumnSparse::compareColumn(const IColumn & rhs, size_t rhs_row_num,
|
||||
PaddedPODArray<UInt64> * row_indexes, PaddedPODArray<Int8> & compare_results,
|
||||
int direction, int nan_direction_hint) const
|
||||
{
|
||||
if (row_indexes)
|
||||
if (row_indexes || !typeid_cast<const ColumnSparse *>(&rhs))
|
||||
{
|
||||
/// TODO: implement without conversion to full column.
|
||||
auto this_full = convertToFullColumnIfSparse();
|
||||
|
@ -159,7 +159,7 @@ void PartialSortingTransform::transform(Chunk & chunk)
|
||||
{
|
||||
MutableColumnPtr sort_description_threshold_column_updated = raw_block_columns[i]->cloneEmpty();
|
||||
sort_description_threshold_column_updated->insertFrom(*raw_block_columns[i], min_row_to_compare);
|
||||
sort_description_threshold_columns_updated[i] = std::move(sort_description_threshold_column_updated);
|
||||
sort_description_threshold_columns_updated[i] = sort_description_threshold_column_updated->convertToFullColumnIfSparse();
|
||||
}
|
||||
|
||||
sort_description_threshold_columns = std::move(sort_description_threshold_columns_updated);
|
||||
|
@ -0,0 +1 @@
|
||||
65536
|
@ -0,0 +1,12 @@
|
||||
DROP TABLE IF EXISTS t_sparse_sort_limit;
|
||||
|
||||
CREATE TABLE t_sparse_sort_limit (date Date, i UInt64, v Int16)
|
||||
ENGINE = MergeTree ORDER BY (date, i)
|
||||
SETTINGS ratio_of_defaults_for_sparse_serialization = 0.9;
|
||||
|
||||
INSERT INTO t_sparse_sort_limit SELECT '2020-10-10', number % 10, number FROM numbers(100000);
|
||||
INSERT INTO t_sparse_sort_limit SELECT '2020-10-11', number % 10, number FROM numbers(100000);
|
||||
|
||||
SELECT count() FROM (SELECT toStartOfMonth(date) AS d FROM t_sparse_sort_limit ORDER BY -i LIMIT 65536);
|
||||
|
||||
DROP TABLE IF EXISTS t_sparse_sort_limit;
|
Loading…
Reference in New Issue
Block a user