mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #37653 from vdimir/cross_join_dup_col_names
This commit is contained in:
commit
2a38fdb796
@ -707,6 +707,13 @@ namespace
|
||||
|
||||
void HashJoin::initRightBlockStructure(Block & saved_block_sample)
|
||||
{
|
||||
if (isCrossOrComma(kind))
|
||||
{
|
||||
/// cross join doesn't have keys, just add all columns
|
||||
saved_block_sample = sample_block_with_columns_to_add.cloneEmpty();
|
||||
return;
|
||||
}
|
||||
|
||||
bool multiple_disjuncts = !table_join->oneDisjunct();
|
||||
/// We could remove key columns for LEFT | INNER HashJoin but we should keep them for JoinSwitcher (if any).
|
||||
bool save_key_columns = !table_join->forceHashJoin() || isRightOrFull(kind) || multiple_disjuncts;
|
||||
@ -724,9 +731,7 @@ void HashJoin::initRightBlockStructure(Block & saved_block_sample)
|
||||
for (auto & column : sample_block_with_columns_to_add)
|
||||
{
|
||||
if (!saved_block_sample.findByName(column.name))
|
||||
{
|
||||
saved_block_sample.insert(column);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1184,7 +1184,7 @@ TreeRewriterResultPtr TreeRewriter::analyzeSelect(
|
||||
if (remove_duplicates)
|
||||
renameDuplicatedColumns(select_query);
|
||||
|
||||
/// Perform it before analyzing JOINs, because it may change number of columns with names unique and break some login inside JOINs
|
||||
/// Perform it before analyzing JOINs, because it may change number of columns with names unique and break some logic inside JOINs
|
||||
if (settings.optimize_normalize_count_variants)
|
||||
TreeOptimizer::optimizeCountConstantAndSumOne(query);
|
||||
|
||||
|
@ -0,0 +1,2 @@
|
||||
\N
|
||||
\N
|
16
tests/queries/0_stateless/02313_cross_join_dup_col_names.sql
Normal file
16
tests/queries/0_stateless/02313_cross_join_dup_col_names.sql
Normal file
@ -0,0 +1,16 @@
|
||||
-- Tags: no-backward-compatibility-check
|
||||
|
||||
-- https://github.com/ClickHouse/ClickHouse/issues/37561
|
||||
|
||||
SELECT NULL
|
||||
FROM
|
||||
(SELECT NULL) AS s1,
|
||||
(SELECT count(2), count(1)) AS s2
|
||||
;
|
||||
|
||||
SELECT NULL
|
||||
FROM
|
||||
(SELECT NULL) AS s1,
|
||||
(SELECT count(2.), 9223372036854775806, count('-1'), NULL) AS s2,
|
||||
(SELECT count('-2147483648')) AS any_query, (SELECT NULL) AS check_single_query
|
||||
;
|
Loading…
Reference in New Issue
Block a user