mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Fix hashing of empty tuples
This commit is contained in:
parent
085b0c1815
commit
919bbf57a7
@ -1223,6 +1223,9 @@ private:
|
||||
else executeGeneric<first>(key_cols, icolumn, vec_to);
|
||||
}
|
||||
|
||||
/// Return a fixed random-looking magic number when input is empty.
|
||||
static constexpr auto filler = 0xe28dbde7fe22e41c;
|
||||
|
||||
void executeForArgument(const KeyColumnsType & key_cols, const IDataType * type, const IColumn * column, typename ColumnVector<ToType>::Container & vec_to, bool & is_first) const
|
||||
{
|
||||
/// Flattening of tuples.
|
||||
@ -1231,6 +1234,11 @@ private:
|
||||
const auto & tuple_columns = tuple->getColumns();
|
||||
const DataTypes & tuple_types = typeid_cast<const DataTypeTuple &>(*type).getElements();
|
||||
size_t tuple_size = tuple_columns.size();
|
||||
|
||||
if (0 == tuple_size && is_first)
|
||||
for (auto & hash : vec_to)
|
||||
hash = static_cast<ToType>(filler);
|
||||
|
||||
for (size_t i = 0; i < tuple_size; ++i)
|
||||
executeForArgument(key_cols, tuple_types[i].get(), tuple_columns[i].get(), vec_to, is_first);
|
||||
}
|
||||
@ -1239,6 +1247,11 @@ private:
|
||||
const auto & tuple_columns = tuple_const->getColumns();
|
||||
const DataTypes & tuple_types = typeid_cast<const DataTypeTuple &>(*type).getElements();
|
||||
size_t tuple_size = tuple_columns.size();
|
||||
|
||||
if (0 == tuple_size && is_first)
|
||||
for (auto & hash : vec_to)
|
||||
hash = static_cast<ToType>(filler);
|
||||
|
||||
for (size_t i = 0; i < tuple_size; ++i)
|
||||
{
|
||||
auto tmp = ColumnConst::create(tuple_columns[i], column->size());
|
||||
@ -1300,10 +1313,7 @@ public:
|
||||
constexpr size_t first_data_argument = Keyed;
|
||||
|
||||
if (arguments.size() <= first_data_argument)
|
||||
{
|
||||
/// Return a fixed random-looking magic number when input is empty
|
||||
vec_to.assign(input_rows_count, static_cast<ToType>(0xe28dbde7fe22e41c));
|
||||
}
|
||||
vec_to.assign(input_rows_count, static_cast<ToType>(filler));
|
||||
|
||||
KeyColumnsType key_cols{};
|
||||
if constexpr (Keyed)
|
||||
|
@ -0,0 +1,22 @@
|
||||
16324913028386710556
|
||||
16324913028386710556
|
||||
5049034479224883533
|
||||
7385293435322750976
|
||||
12248912094175844631
|
||||
5049034479224883533
|
||||
5887129541803688833
|
||||
5887129541803688833
|
||||
13747979201178469747
|
||||
5887129541803688833
|
||||
15520217392480966957
|
||||
16324913028386710556
|
||||
16324913028386710556
|
||||
5049034479224883533
|
||||
7385293435322750976
|
||||
12248912094175844631
|
||||
5049034479224883533
|
||||
5887129541803688833
|
||||
5887129541803688833
|
||||
13747979201178469747
|
||||
5887129541803688833
|
||||
15520217392480966957
|
23
tests/queries/0_stateless/03205_hashing_empty_tuples.sql
Normal file
23
tests/queries/0_stateless/03205_hashing_empty_tuples.sql
Normal file
@ -0,0 +1,23 @@
|
||||
SELECT sipHash64(());
|
||||
SELECT sipHash64((), ());
|
||||
SELECT sipHash64((), 1);
|
||||
SELECT sipHash64(1, ());
|
||||
SELECT sipHash64(1, (), 1);
|
||||
SELECT sipHash64((), 1, ());
|
||||
SELECT sipHash64((), (1, 2));
|
||||
SELECT sipHash64((), (1, 2));
|
||||
SELECT sipHash64((1, 2), ());
|
||||
SELECT sipHash64((), (1, 2), ());
|
||||
SELECT sipHash64((1, 2), (), (3, 4));
|
||||
|
||||
SELECT sipHash64(materialize(()));
|
||||
SELECT sipHash64(materialize(()), materialize(()));
|
||||
SELECT sipHash64(materialize(()), 1);
|
||||
SELECT sipHash64(1, materialize(()));
|
||||
SELECT sipHash64(1, materialize(()), 1);
|
||||
SELECT sipHash64((), 1, materialize(()));
|
||||
SELECT sipHash64(materialize(()), (1, 2));
|
||||
SELECT sipHash64(materialize(()), (1, 2));
|
||||
SELECT sipHash64((1, 2), materialize(()));
|
||||
SELECT sipHash64(materialize(()), (1, 2), ());
|
||||
SELECT sipHash64((1, 2), materialize(()), (3, 4));
|
Loading…
Reference in New Issue
Block a user