mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 16:50:48 +00:00
Add additional checkTypesOfKeys to JoiningTransform::transformHeader
This commit is contained in:
parent
4b3c0a95d1
commit
1fdbb9509f
@ -1387,6 +1387,11 @@ ColumnWithTypeAndName HashJoin::joinGet(const Block & block, const Block & block
|
||||
return keys.getByPosition(keys.columns() - 1);
|
||||
}
|
||||
|
||||
void HashJoin::checkTypesOfKeys(const Block & block) const
|
||||
{
|
||||
JoinCommon::checkTypesOfKeys(block, table_join->keyNamesLeft(), right_table_keys, key_names_right);
|
||||
}
|
||||
|
||||
void HashJoin::joinBlock(Block & block, ExtraBlockPtr & not_processed)
|
||||
{
|
||||
const Names & key_names_left = table_join->keyNamesLeft();
|
||||
|
@ -140,6 +140,8 @@ public:
|
||||
*/
|
||||
bool addJoinedBlock(const Block & block, bool check_limits) override;
|
||||
|
||||
void checkTypesOfKeys(const Block & block) const override;
|
||||
|
||||
/** Join data from the map (that was previously built by calls to addJoinedBlock) to the block with data from "left" table.
|
||||
* Could be called from different threads in parallel.
|
||||
*/
|
||||
|
@ -27,6 +27,8 @@ public:
|
||||
/// @returns false, if some limit was exceeded and you should not insert more data.
|
||||
virtual bool addJoinedBlock(const Block & block, bool check_limits = true) = 0;
|
||||
|
||||
virtual void checkTypesOfKeys(const Block & block) const = 0;
|
||||
|
||||
/// Join the block with data from left hand of JOIN to the right hand data (that was previously built by calls to addJoinedBlock).
|
||||
/// Could be called from different threads in parallel.
|
||||
virtual void joinBlock(Block & block, std::shared_ptr<ExtraBlock> & not_processed) = 0;
|
||||
|
@ -26,6 +26,11 @@ public:
|
||||
/// @returns false, if join-on-disk disk limit exceeded
|
||||
bool addJoinedBlock(const Block & block, bool check_limits) override;
|
||||
|
||||
void checkTypesOfKeys(const Block & block) const override
|
||||
{
|
||||
join->checkTypesOfKeys(block);
|
||||
}
|
||||
|
||||
void joinBlock(Block & block, std::shared_ptr<ExtraBlock> & not_processed) override
|
||||
{
|
||||
join->joinBlock(block, not_processed);
|
||||
|
@ -666,16 +666,24 @@ bool MergeJoin::addJoinedBlock(const Block & src_block, bool)
|
||||
return saveRightBlock(std::move(block));
|
||||
}
|
||||
|
||||
void MergeJoin::checkTypesOfKeys(const Block & block) const
|
||||
{
|
||||
/// Do not check auxailary column for extra conditions, use original key names
|
||||
JoinCommon::checkTypesOfKeys(block, table_join->keyNamesLeft(), right_table_keys, table_join->keyNamesRight());
|
||||
}
|
||||
|
||||
void MergeJoin::joinBlock(Block & block, ExtraBlockPtr & not_processed)
|
||||
{
|
||||
Names lowcard_keys = lowcard_right_keys;
|
||||
if (block)
|
||||
{
|
||||
/// We need to check type of masks before `addConditionJoinColumn`, because it assumes that types is correct
|
||||
JoinCommon::checkTypesOfMasks(block, mask_column_name_left, right_sample_block, mask_column_name_right);
|
||||
|
||||
/// Add auxiliary column, will be removed after joining
|
||||
addConditionJoinColumn(block, JoinTableSide::Left);
|
||||
|
||||
/// Types of keys can be checked only after `checkTypesOfKeys`
|
||||
JoinCommon::checkTypesOfKeys(block, key_names_left, right_table_keys, key_names_right);
|
||||
|
||||
materializeBlockInplace(block);
|
||||
|
@ -25,6 +25,7 @@ public:
|
||||
|
||||
const TableJoin & getTableJoin() const override { return *table_join; }
|
||||
bool addJoinedBlock(const Block & block, bool check_limits) override;
|
||||
void checkTypesOfKeys(const Block & block) const override;
|
||||
void joinBlock(Block &, ExtraBlockPtr & not_processed) override;
|
||||
|
||||
void setTotals(const Block &) override;
|
||||
|
@ -399,7 +399,7 @@ void checkTypesOfKeys(const Block & block_left, const Names & key_names_left,
|
||||
void checkTypesOfKeys(const Block & block_left, const Names & key_names_left, const String & condition_name_left,
|
||||
const Block & block_right, const Names & key_names_right, const String & condition_name_right)
|
||||
{
|
||||
checkTypesOfKeys(block_left, key_names_left,block_right,key_names_right);
|
||||
checkTypesOfKeys(block_left, key_names_left, block_right, key_names_right);
|
||||
checkTypesOfMasks(block_left, condition_name_left, block_right, condition_name_right);
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,9 @@ namespace ErrorCodes
|
||||
|
||||
Block JoiningTransform::transformHeader(Block header, const JoinPtr & join)
|
||||
{
|
||||
ExtraBlockPtr tmp;
|
||||
LOG_DEBUG(&Poco::Logger::get("JoiningTransform"), "Before join block: '{}'", header.dumpStructure());
|
||||
join->checkTypesOfKeys(header);
|
||||
ExtraBlockPtr tmp;
|
||||
join->joinBlock(header, tmp);
|
||||
LOG_DEBUG(&Poco::Logger::get("JoiningTransform"), "After join block: '{}'", header.dumpStructure());
|
||||
return header;
|
||||
|
@ -7,3 +7,4 @@
|
||||
1 0 1
|
||||
1 1 0
|
||||
1 1 1
|
||||
-
|
||||
|
@ -9,4 +9,7 @@ SELECT * FROM ints l LEFT JOIN ints r USING i64 ORDER BY l.i32, r.i32;
|
||||
SELECT '-';
|
||||
SELECT * FROM ints l INNER JOIN ints r USING i64 ORDER BY l.i32, r.i32;
|
||||
|
||||
SELECT '-';
|
||||
SELECT count() FROM ( SELECT [1], count(1) ) AS t1 ALL RIGHT JOIN ( SELECT number AS s FROM numbers(2) ) AS t2 USING (s); -- { serverError NOT_FOUND_COLUMN_IN_BLOCK }
|
||||
|
||||
DROP TABLE ints;
|
||||
|
@ -48,10 +48,10 @@ SELECT DISTINCT t1.id FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND toLowCardi
|
||||
SELECT DISTINCT t1.id FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND toNullable(toLowCardinality(t1.key2 != ''));
|
||||
|
||||
SELECT '--';
|
||||
SELECT DISTINCT t1.key, toUInt8(t1.id) as e FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND e;
|
||||
SELECT DISTINCT t1.key, toUInt8(t1.id) as e FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND e;
|
||||
-- `e + 1` is UInt16
|
||||
SELECT DISTINCT t1.key, toUInt8(t1.id) as e FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND e + 1; -- { serverError 403 }
|
||||
SELECT DISTINCT t1.key, toUInt8(t1.id) as e FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND toUInt8(e + 1);
|
||||
SELECT DISTINCT t1.key, toUInt8(t1.id) as e FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND toUInt8(e + 1);
|
||||
|
||||
SELECT '--';
|
||||
SELECT t1.id, t1.key, t1.key2, t2.id, t2.key, t2.key2 FROM t1 FULL JOIN t2 ON t1.id == t2.id AND t2.key == t2.key2 AND t1.key == t1.key2 ORDER BY t1.id, t2.id;
|
||||
@ -110,10 +110,10 @@ SELECT DISTINCT t1.id FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND toLowCardi
|
||||
SELECT DISTINCT t1.id FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND toNullable(toLowCardinality(t1.key2 != ''));
|
||||
|
||||
SELECT '--';
|
||||
SELECT DISTINCT t1.key, toUInt8(t1.id) as e FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND e;
|
||||
SELECT DISTINCT t1.key, toUInt8(t1.id) as e FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND e;
|
||||
-- `e + 1` is UInt16
|
||||
SELECT DISTINCT t1.key, toUInt8(t1.id) as e FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND e + 1; -- { serverError 403 }
|
||||
SELECT DISTINCT t1.key, toUInt8(t1.id) as e FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND toUInt8(e + 1);
|
||||
SELECT DISTINCT t1.key, toUInt8(t1.id) as e FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND toUInt8(e + 1);
|
||||
|
||||
SELECT '--';
|
||||
SELECT t1.id, t1.key, t1.key2, t2.id, t2.key, t2.key2 FROM t1 FULL JOIN t2 ON t1.id == t2.id AND t2.key == t2.key2 AND t1.key == t1.key2 ORDER BY t1.id, t2.id;
|
||||
|
Loading…
Reference in New Issue
Block a user