mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +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_ident = alias->clone();
|
||||
alias_ident->as<ASTIdentifier>()->restoreTable();
|
||||
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);
|
||||
if (auto * alias_ident_typed = alias_ident->as<ASTIdentifier>())
|
||||
{
|
||||
alias_ident_typed->restoreTable();
|
||||
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 original_long_name;
|
||||
|
@ -1 +1,2 @@
|
||||
b
|
||||
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 1 AS id, 'a' AS test) a
|
||||
LEFT JOIN (SELECT 1 AS id, 'b' AS test) b ON b.id = a.id
|
||||
|
Loading…
Reference in New Issue
Block a user