mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fix invalid header for (LowCardinality IN (tuple)).
This commit is contained in:
parent
e5f49477a6
commit
b6fc471270
@ -3,10 +3,12 @@
|
|||||||
#include <Functions/FunctionHelpers.h>
|
#include <Functions/FunctionHelpers.h>
|
||||||
#include <DataTypes/DataTypeTuple.h>
|
#include <DataTypes/DataTypeTuple.h>
|
||||||
#include <DataTypes/DataTypesNumber.h>
|
#include <DataTypes/DataTypesNumber.h>
|
||||||
|
#include <DataTypes/DataTypeLowCardinality.h>
|
||||||
#include <Columns/ColumnConst.h>
|
#include <Columns/ColumnConst.h>
|
||||||
#include <Columns/ColumnsNumber.h>
|
#include <Columns/ColumnsNumber.h>
|
||||||
#include <Columns/ColumnTuple.h>
|
#include <Columns/ColumnTuple.h>
|
||||||
#include <Columns/ColumnSet.h>
|
#include <Columns/ColumnSet.h>
|
||||||
|
#include <Columns/ColumnLowCardinality.h>
|
||||||
#include <Interpreters/Set.h>
|
#include <Interpreters/Set.h>
|
||||||
|
|
||||||
|
|
||||||
@ -67,6 +69,12 @@ public:
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Do not use default implementation for LowCardinality.
|
||||||
|
/// For now, Set may be const or non const column, depending on how it was created.
|
||||||
|
/// But we will return UInt8 for any case.
|
||||||
|
/// TODO: we could use special implementation later.
|
||||||
|
bool useDefaultImplementationForLowCardinalityColumns() const override { return false; }
|
||||||
|
|
||||||
DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override
|
DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override
|
||||||
{
|
{
|
||||||
return std::make_shared<DataTypeUInt8>();
|
return std::make_shared<DataTypeUInt8>();
|
||||||
@ -122,7 +130,28 @@ public:
|
|||||||
else
|
else
|
||||||
columns_of_key_columns.insert(left_arg);
|
columns_of_key_columns.insert(left_arg);
|
||||||
|
|
||||||
return set->execute(columns_of_key_columns, negative);
|
ColumnPtr lc_indexes = nullptr;
|
||||||
|
if (columns_of_key_columns.columns() == 1)
|
||||||
|
{
|
||||||
|
auto & arg = columns_of_key_columns.safeGetByPosition(0);
|
||||||
|
const auto * col = arg.column.get();
|
||||||
|
if (const auto * const_col = typeid_cast<const ColumnConst *>(col))
|
||||||
|
col = &const_col->getDataColumn();
|
||||||
|
|
||||||
|
if (const auto * lc = typeid_cast<const ColumnLowCardinality *>(col))
|
||||||
|
{
|
||||||
|
lc_indexes = lc->getIndexesPtr();
|
||||||
|
arg.column = lc->getDictionary().getNestedColumn();
|
||||||
|
arg.type = removeLowCardinality(arg.type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto res = set->execute(columns_of_key_columns, negative);
|
||||||
|
|
||||||
|
if (lc_indexes)
|
||||||
|
return res->index(*lc_indexes, 0);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
2
tests/queries/0_stateless/01906_lc_in_bug.reference
Normal file
2
tests/queries/0_stateless/01906_lc_in_bug.reference
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
1 0
|
||||||
|
3 1
|
8
tests/queries/0_stateless/01906_lc_in_bug.sql
Normal file
8
tests/queries/0_stateless/01906_lc_in_bug.sql
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
drop table if exists tab;
|
||||||
|
create table tab (x LowCardinality(String)) engine = MergeTree order by tuple();
|
||||||
|
|
||||||
|
insert into tab values ('a'), ('bb'), ('a'), ('cc');
|
||||||
|
|
||||||
|
select count() as c, x in ('a', 'bb') as g from tab group by g order by c;
|
||||||
|
|
||||||
|
drop table if exists tab;
|
Loading…
Reference in New Issue
Block a user