Fix bad cast in arrayIndex #26330

This commit is contained in:
Alexey Milovidov 2021-08-15 09:33:08 +03:00
parent 8a843ae15f
commit 15eb68d117
3 changed files with 9 additions and 0 deletions

View File

@ -115,6 +115,13 @@ private:
[[maybe_unused]] const NullMap * const null_map_data,
[[maybe_unused]] const NullMap * const null_map_item)
{
if constexpr (std::is_same_v<Data, IColumn> && std::is_same_v<Target, IColumn>)
{
/// Generic variant is using IColumn::compare function that only allows to compare columns of identical types.
if (typeid(data) != typeid(target))
throw Exception(ErrorCodes::ILLEGAL_COLUMN, "Columns {} and {} cannot be compared", data.getName(), target.getName());
}
const size_t size = offsets.size();
result.resize(size);

View File

@ -0,0 +1,2 @@
-- This query throws exception about uncomparable data types (but at least it does not introduce bad cast in code).
SELECT has(materialize(CAST(['2021-07-14'] AS Array(LowCardinality(Nullable(DateTime))))), materialize('2021-07-14'::DateTime64(7))); -- { serverError 44 }