mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-29 13:10:48 +00:00
Update all StorageInMemoryMetadata::check overloads
This commit is contained in:
parent
987421862a
commit
1984940eb6
@ -501,12 +501,12 @@ namespace
|
||||
* 2. The first type can represent all possible values of the second one.
|
||||
* 3. Both types require the same amount of memory.
|
||||
*/
|
||||
bool isCompatibleEnumTypes(const IDataType* lhs, const DataTypePtr& rhs)
|
||||
bool isCompatibleEnumTypes(const IDataType * lhs, const IDataType * rhs)
|
||||
{
|
||||
WhichDataType which{lhs};
|
||||
if (!which.isEnum())
|
||||
return false;
|
||||
IDataTypeEnum const* enum_type = dynamic_cast<IDataTypeEnum const*>(lhs);
|
||||
IDataTypeEnum const * enum_type = dynamic_cast<IDataTypeEnum const *>(lhs);
|
||||
if (!enum_type->contains(*rhs))
|
||||
return false;
|
||||
return enum_type->getMaximumSizeOfValueInMemory() == rhs->getMaximumSizeOfValueInMemory();
|
||||
@ -562,13 +562,13 @@ void StorageInMemoryMetadata::check(const NamesAndTypesList & provided_columns)
|
||||
column.name,
|
||||
listOfColumns(available_columns));
|
||||
|
||||
auto const mapped_type = it->getMapped();
|
||||
if (!column.type->equals(*mapped_type) && !isCompatibleEnumTypes(mapped_type, column.type))
|
||||
const auto * available_type = it->getMapped();
|
||||
if (!column.type->equals(*available_type) && !isCompatibleEnumTypes(available_type, column.type.get()))
|
||||
throw Exception(
|
||||
ErrorCodes::TYPE_MISMATCH,
|
||||
"Type mismatch for column {}. Column has type {}, got type {}",
|
||||
column.name,
|
||||
mapped_type->getName(),
|
||||
available_type->getName(),
|
||||
column.type->getName());
|
||||
|
||||
if (unique_names.end() != unique_names.find(column.name))
|
||||
@ -607,16 +607,16 @@ void StorageInMemoryMetadata::check(const NamesAndTypesList & provided_columns,
|
||||
name,
|
||||
listOfColumns(available_columns));
|
||||
|
||||
const auto & provided_column_type = *it->getMapped();
|
||||
const auto & available_column_type = *jt->getMapped();
|
||||
const auto * provided_column_type = it->getMapped();
|
||||
const auto * available_column_type = jt->getMapped();
|
||||
|
||||
if (!provided_column_type.equals(available_column_type))
|
||||
if (!provided_column_type->equals(*available_column_type) && !isCompatibleEnumTypes(available_column_type, provided_column_type))
|
||||
throw Exception(
|
||||
ErrorCodes::TYPE_MISMATCH,
|
||||
"Type mismatch for column {}. Column has type {}, got type {}",
|
||||
name,
|
||||
provided_column_type.getName(),
|
||||
available_column_type.getName());
|
||||
available_column_type->getName(),
|
||||
provided_column_type->getName());
|
||||
|
||||
if (unique_names.end() != unique_names.find(name))
|
||||
throw Exception(ErrorCodes::COLUMN_QUERIED_MORE_THAN_ONCE,
|
||||
@ -651,12 +651,13 @@ void StorageInMemoryMetadata::check(const Block & block, bool need_all) const
|
||||
column.name,
|
||||
listOfColumns(available_columns));
|
||||
|
||||
if (!column.type->equals(*it->getMapped()))
|
||||
const auto * available_type = it->getMapped();
|
||||
if (!column.type->equals(*available_type) && !isCompatibleEnumTypes(available_type, column.type.get()))
|
||||
throw Exception(
|
||||
ErrorCodes::TYPE_MISMATCH,
|
||||
"Type mismatch for column {}. Column has type {}, got type {}",
|
||||
column.name,
|
||||
it->getMapped()->getName(),
|
||||
available_type->getName(),
|
||||
column.type->getName());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user