mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 17:32:32 +00:00
Add the optimize_type_ids parameter to control whether optimization is enabled.
This commit is contained in:
parent
57d69a10e3
commit
41e8345169
@ -155,7 +155,7 @@ DataTypePtr FieldToDataType<on_error>::operator() (const Array & x) const
|
|||||||
for (const Field & elem : x)
|
for (const Field & elem : x)
|
||||||
element_types.emplace_back(applyVisitor(*this, elem));
|
element_types.emplace_back(applyVisitor(*this, elem));
|
||||||
|
|
||||||
return std::make_shared<DataTypeArray>(getLeastSupertype<on_error>(element_types));
|
return std::make_shared<DataTypeArray>(getLeastSupertype<on_error>(element_types, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <LeastSupertypeOnError on_error>
|
template <LeastSupertypeOnError on_error>
|
||||||
|
@ -201,7 +201,7 @@ DataTypePtr getNumericType(const TypeIndexSet & types)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <LeastSupertypeOnError on_error>
|
template <LeastSupertypeOnError on_error>
|
||||||
DataTypePtr getLeastSupertype(const DataTypes & types)
|
DataTypePtr getLeastSupertype(const DataTypes & types, bool optimize_type_ids)
|
||||||
{
|
{
|
||||||
/// Trivial cases
|
/// Trivial cases
|
||||||
|
|
||||||
@ -592,7 +592,8 @@ DataTypePtr getLeastSupertype(const DataTypes & types)
|
|||||||
|
|
||||||
/// For numeric types, the most complicated part.
|
/// For numeric types, the most complicated part.
|
||||||
{
|
{
|
||||||
optimizeTypeIds(types, type_ids);
|
if (optimize_type_ids)
|
||||||
|
optimizeTypeIds(types, type_ids);
|
||||||
auto numeric_type = getNumericType<on_error>(type_ids);
|
auto numeric_type = getNumericType<on_error>(type_ids);
|
||||||
if (numeric_type)
|
if (numeric_type)
|
||||||
return numeric_type;
|
return numeric_type;
|
||||||
@ -798,7 +799,7 @@ DataTypePtr tryGetLeastSupertype(const TypeIndexSet & types)
|
|||||||
return getLeastSupertype<LeastSupertypeOnError::Null>(types);
|
return getLeastSupertype<LeastSupertypeOnError::Null>(types);
|
||||||
}
|
}
|
||||||
|
|
||||||
template DataTypePtr getLeastSupertype<LeastSupertypeOnError::Throw>(const DataTypes & types);
|
template DataTypePtr getLeastSupertype<LeastSupertypeOnError::Throw>(const DataTypes & types, bool optimize_type_ids);
|
||||||
template DataTypePtr getLeastSupertype<LeastSupertypeOnError::Throw>(const TypeIndexSet & types);
|
template DataTypePtr getLeastSupertype<LeastSupertypeOnError::Throw>(const TypeIndexSet & types);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ enum class LeastSupertypeOnError
|
|||||||
* Examples: there is no least common supertype for Array(UInt8), Int8.
|
* Examples: there is no least common supertype for Array(UInt8), Int8.
|
||||||
*/
|
*/
|
||||||
template <LeastSupertypeOnError on_error = LeastSupertypeOnError::Throw>
|
template <LeastSupertypeOnError on_error = LeastSupertypeOnError::Throw>
|
||||||
DataTypePtr getLeastSupertype(const DataTypes & types);
|
DataTypePtr getLeastSupertype(const DataTypes & types, bool optimize_type_ids = false);
|
||||||
|
|
||||||
/// Same as above but return String type instead of throwing exception.
|
/// Same as above but return String type instead of throwing exception.
|
||||||
/// All types can be casted to String, because they can be serialized to String.
|
/// All types can be casted to String, because they can be serialized to String.
|
||||||
|
Loading…
Reference in New Issue
Block a user