Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #48998 to 23.3: Fix incorrect createColumn call on join clause #54424

Merged
merged 3 commits into from Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/Interpreters/ExpressionAnalyzer.cpp
Expand Up @@ -1020,13 +1020,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;
Expand Down Expand Up @@ -1072,7 +1065,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());
}

Expand Down
@@ -0,0 +1 @@
1
@@ -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