Skip to content

Commit

Permalink
Using IDataType::equals to compare for type equivalence ClickHouse#1650
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-milovidov committed Dec 23, 2017
1 parent a1fe019 commit b5af4c9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dbms/src/Core/NamesAndTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct NameAndTypePair

bool operator==(const NameAndTypePair & rhs) const
{
return name == rhs.name && type->getName() == rhs.type->getName();
return name == rhs.name && type->equals(*rhs.type);
}
};

Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/AlterCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ void AlterCommands::validate(IStorage * table, const Context & context)
const auto & deduced_type = tmp_column.type;

// column not specified explicitly in the ALTER query may require default_expression modification
if (explicit_type->getName() != deduced_type->getName())
if (!explicit_type->equals(*deduced_type))
{
const auto default_it = defaults.find(column_name);

Expand Down
4 changes: 2 additions & 2 deletions dbms/src/Storages/ITableDeclaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void ITableDeclaration::check(const NamesAndTypesList & columns) const
throw Exception("There is no column with name " + column.name + ". There are columns: "
+ listOfColumns(available_columns), ErrorCodes::NO_SUCH_COLUMN_IN_TABLE);

if (column.type->getName() != it->second->getName())
if (!column.type->equals(*it->second))
throw Exception("Type mismatch for column " + column.name + ". Column has type "
+ it->second->getName() + ", got type " + column.type->getName(), ErrorCodes::TYPE_MISMATCH);

Expand Down Expand Up @@ -274,7 +274,7 @@ void ITableDeclaration::check(const Block & block, bool need_all) const
throw Exception("There is no column with name " + column.name + ". There are columns: "
+ listOfColumns(available_columns), ErrorCodes::NO_SUCH_COLUMN_IN_TABLE);

if (column.type->getName() != it->second->getName())
if (!column.type->equals(*it->second))
throw Exception("Type mismatch for column " + column.name + ". Column has type "
+ it->second->getName() + ", got type " + column.type->getName(), ErrorCodes::TYPE_MISMATCH);
}
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/StorageBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ void StorageBuffer::writeBlockToDestination(const Block & block, StoragePtr tabl
auto dst_col = structure_of_destination_table.getByPosition(i);
if (block.has(dst_col.name))
{
if (block.getByName(dst_col.name).type->getName() != dst_col.type->getName())
if (!block.getByName(dst_col.name).type->equals(*dst_col.type))
{
LOG_ERROR(log, "Destination table " << destination_database << "." << destination_table
<< " have different type of column " << dst_col.name << " ("
Expand Down

0 comments on commit b5af4c9

Please sign in to comment.