diff --git a/dbms/include/DB/Interpreters/Join.h b/dbms/include/DB/Interpreters/Join.h index 034390e8492..ca9983348d5 100644 --- a/dbms/include/DB/Interpreters/Join.h +++ b/dbms/include/DB/Interpreters/Join.h @@ -250,6 +250,9 @@ private: /// Проверить не превышены ли допустимые размеры множества bool checkSizeLimits() const; + + /// Кинуть исключение, если в блоках не совпадают типы ключей. + void checkTypesOfKeys(const Block & block_left, const Block & block_right) const; }; typedef Poco::SharedPtr JoinPtr; diff --git a/dbms/src/Interpreters/Join.cpp b/dbms/src/Interpreters/Join.cpp index b614c76fa57..3a3c84b19a8 100644 --- a/dbms/src/Interpreters/Join.cpp +++ b/dbms/src/Interpreters/Join.cpp @@ -650,10 +650,25 @@ void Join::joinBlockImpl(Block & block, const Maps & maps) const } +void Join::checkTypesOfKeys(const Block & block_left, const Block & block_right) const +{ + size_t keys_size = key_names_left.size(); + + for (size_t i = 0; i < keys_size; ++i) + if (block_left.getByName(key_names_left[i]).type->getName() != block_right.getByName(key_names_right[i]).type->getName()) + throw Exception("Type mismatch of columns to JOIN by: " + + key_names_left[i] + " " + block_left.getByName(key_names_left[i]).type->getName() + " at left, " + + key_names_right[i] + " " + block_right.getByName(key_names_right[i]).type->getName() + " at right, ", + ErrorCodes::TYPE_MISMATCH); +} + + void Join::joinBlock(Block & block) const { Poco::ScopedReadRWLock lock(rwlock); +// checkTypesOfKeys(block, sample_block); + if (kind == ASTJoin::Left && strictness == ASTJoin::Any) joinBlockImpl(block, maps_any); else if (kind == ASTJoin::Inner && strictness == ASTJoin::Any)