mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
Merge pull request #42883 from zzsmdfj/fix_join_to_subqueries_null_pointer
Fix join to subqueries rewriter null pointer
This commit is contained in:
commit
6995fa1afd
@ -546,10 +546,13 @@ std::vector<TableNeededColumns> normalizeColumnNamesExtractNeeded(
|
|||||||
{
|
{
|
||||||
auto alias = aliases.find(ident->name())->second;
|
auto alias = aliases.find(ident->name())->second;
|
||||||
auto alias_ident = alias->clone();
|
auto alias_ident = alias->clone();
|
||||||
alias_ident->as<ASTIdentifier>()->restoreTable();
|
if (auto * alias_ident_typed = alias_ident->as<ASTIdentifier>())
|
||||||
bool alias_equals_column_name = alias_ident->getColumnNameWithoutAlias() == ident->getColumnNameWithoutAlias();
|
{
|
||||||
if (!alias_equals_column_name)
|
alias_ident_typed->restoreTable();
|
||||||
throw Exception("Alias clashes with qualified column '" + ident->name() + "'", ErrorCodes::AMBIGUOUS_COLUMN_NAME);
|
bool alias_equals_column_name = alias_ident->getColumnNameWithoutAlias() == ident->getColumnNameWithoutAlias();
|
||||||
|
if (!alias_equals_column_name)
|
||||||
|
throw Exception("Alias clashes with qualified column '" + ident->name() + "'", ErrorCodes::AMBIGUOUS_COLUMN_NAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String short_name = ident->shortName();
|
String short_name = ident->shortName();
|
||||||
String original_long_name;
|
String original_long_name;
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
b
|
||||||
a b c
|
a b c
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
SELECT (if(a.test == 'a', b.test, c.test)) as `a.test` FROM
|
||||||
|
(SELECT 1 AS id, 'a' AS test) a
|
||||||
|
LEFT JOIN (SELECT 1 AS id, 'b' AS test) b ON b.id = a.id
|
||||||
|
LEFT JOIN (SELECT 1 AS id, 'c' AS test) c ON c.id = a.id;
|
||||||
|
|
||||||
SELECT COLUMNS('test') FROM
|
SELECT COLUMNS('test') FROM
|
||||||
(SELECT 1 AS id, 'a' AS test) a
|
(SELECT 1 AS id, 'a' AS test) a
|
||||||
LEFT JOIN (SELECT 1 AS id, 'b' AS test) b ON b.id = a.id
|
LEFT JOIN (SELECT 1 AS id, 'b' AS test) b ON b.id = a.id
|
||||||
|
Loading…
Reference in New Issue
Block a user