fix fuzzer

This commit is contained in:
Anton Popov 2023-03-31 02:20:17 +00:00
parent 39b9d00373
commit 1a6cdb3a6f
4 changed files with 11 additions and 5 deletions

View File

@ -128,6 +128,13 @@ bool DataTypeMap::checkKeyType(DataTypePtr key_type)
return true;
}
DataTypePtr DataTypeMap::getNestedTypeWithUnnamedTuple() const
{
const auto & from_array = assert_cast<const DataTypeArray &>(*nested);
const auto & from_tuple = assert_cast<const DataTypeTuple &>(*from_array.getNestedType());
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeTuple>(from_tuple.getElements()));
}
static DataTypePtr create(const ASTPtr & arguments)
{
if (!arguments || arguments->children.size() != 2)

View File

@ -47,6 +47,7 @@ public:
const DataTypePtr & getValueType() const { return value_type; }
DataTypes getKeyValueTypes() const { return {key_type, value_type}; }
const DataTypePtr & getNestedType() const { return nested; }
DataTypePtr getNestedTypeWithUnnamedTuple() const;
SerializationPtr doGetDefaultSerialization() const override;

View File

@ -3106,9 +3106,7 @@ private:
{
/// Recreate array of unnamed tuples because otherwise it may work
/// unexpectedly while converting to array of named tuples.
const auto & from_array = assert_cast<const DataTypeArray &>(*from_type_map->getNestedType());
const auto & from_tuple = assert_cast<const DataTypeTuple &>(*from_array.getNestedType());
from_type_holder = std::make_shared<DataTypeArray>(std::make_shared<DataTypeTuple>(from_tuple.getElements()));
from_type_holder = from_type_map->getNestedTypeWithUnnamedTuple();
from_type = assert_cast<const DataTypeArray *>(from_type_holder.get());
}

View File

@ -137,7 +137,7 @@ struct MapToNestedAdapter : public MapAdapterBase<MapToNestedAdapter<Name, retur
static DataTypePtr extractNestedType(const DataTypeMap & type_map)
{
return type_map.getNestedType();
return type_map.getNestedTypeWithUnnamedTuple();
}
static ColumnPtr extractNestedColumn(const ColumnMap & column_map)
@ -274,7 +274,7 @@ struct MapKeyLikeAdapter
function_column = ColumnFunction::create(pattern_arg.column->size(), std::move(function_base), ColumnsWithTypeAndName{pattern_arg});
}
ColumnWithTypeAndName function_arg{std::move(function_column), std::move(function_type), "__function_map_key_like"};
ColumnWithTypeAndName function_arg{function_column, function_type, "__function_map_key_like"};
arguments = {function_arg, arguments[0]};
MapToNestedAdapter<Name, returns_map>::extractNestedTypesAndColumns(arguments);
}