Merge pull request #3751 from abyss7/issues/3583

Fix `RangeHashedDictionary` getter against `ColumnConst`
This commit is contained in:
alexey-milovidov 2018-12-04 20:28:39 +03:00 committed by GitHub
commit b6ea2d5396
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 10 deletions

View File

@ -84,7 +84,7 @@ public:
}
/// If column stores integers, it returns n-th element transformed to UInt64 using static_cast.
/// If column stores floting point numbers, bits of n-th elements are copied to lower bits of UInt64, the remaining bits are zeros.
/// If column stores floating point numbers, bits of n-th elements are copied to lower bits of UInt64, the remaining bits are zeros.
/// Is used to optimize some computations (in aggregation, for example).
virtual UInt64 get64(size_t /*n*/) const
{

View File

@ -354,7 +354,9 @@ void RangeHashedDictionary::getItemsImpl(
out[i] = static_cast<OutputType>(val_it != std::end(ranges_and_values) ? val_it->value : null_value);
}
else
{
out[i] = static_cast<OutputType>(null_value);
}
}
query_count.fetch_add(ids.size(), std::memory_order_relaxed);

View File

@ -1683,20 +1683,21 @@ private:
template <typename T>
static const PaddedPODArray<T> & getColumnDataAsPaddedPODArray(const IColumn & column, PaddedPODArray<T> & backup_storage)
{
if (const auto vector_col = checkAndGetColumn<ColumnVector<T>>(&column))
if (!column.isColumnConst())
{
return vector_col->getData();
}
if (const auto const_col = checkAndGetColumnConstData<ColumnVector<T>>(&column))
{
return const_col->getData();
if (const auto vector_col = checkAndGetColumn<ColumnVector<T>>(&column))
{
return vector_col->getData();
}
}
// With type conversion, need to use backup storage here
const auto size = column.size();
const auto full_column = column.isColumnConst() ? column.convertToFullColumnIfConst() : column.getPtr();
// With type conversion and const columns we need to use backup storage here
const auto size = full_column->size();
backup_storage.resize(size);
for (size_t i = 0; i < size; ++i)
backup_storage[i] = column.getUInt(i);
backup_storage[i] = full_column->getUInt(i);
return backup_storage;
}