Merge pull request #48998 from ongkong/fix-join-clause-create-column

Fix incorrect createColumn call on join clause
This commit is contained in:
Alexey Milovidov 2023-05-02 02:23:07 +03:00 committed by GitHub
commit 1267fbca1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 8 deletions

View File

@ -1066,13 +1066,6 @@ static std::shared_ptr<IJoin> chooseJoinAlgorithm(
{
const auto & settings = context->getSettings();
Block left_sample_block(left_sample_columns);
for (auto & column : left_sample_block)
{
if (!column.column)
column.column = column.type->createColumn();
}
Block right_sample_block = joined_plan->getCurrentDataStream().header;
std::vector<String> tried_algorithms;
@ -1118,7 +1111,10 @@ static std::shared_ptr<IJoin> chooseJoinAlgorithm(
if (analyzed_join->isEnabledAlgorithm(JoinAlgorithm::GRACE_HASH))
{
tried_algorithms.push_back(toString(JoinAlgorithm::GRACE_HASH));
if (GraceHashJoin::isSupported(analyzed_join))
// Grace hash join requires that columns exist in left_sample_block.
Block left_sample_block(left_sample_columns);
if (sanitizeBlock(left_sample_block, false) && GraceHashJoin::isSupported(analyzed_join))
return std::make_shared<GraceHashJoin>(context, analyzed_join, left_sample_block, right_sample_block, context->getTempDataOnDisk());
}

View File

@ -0,0 +1,8 @@
select count(*)
from (
select 1 as id, [1, 2, 3] as arr
) as sessions
ASOF LEFT JOIN (
select 1 as session_id, 4 as id
) as visitors
ON visitors.session_id <= sessions.id AND arrayFirst(a -> a, arrayMap((a) -> a, sessions.arr)) = visitors.id