mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
proper qualification for CTE, fix tests
This commit is contained in:
parent
409b24b8d8
commit
84fb836ecb
@ -1484,14 +1484,14 @@ void QueryAnalyzer::qualifyColumnNodesWithProjectionNames(const QueryTreeNodes &
|
||||
/// Build additional column qualification parts array
|
||||
std::vector<std::string> additional_column_qualification_parts;
|
||||
|
||||
auto * query_node = table_expression_node->as<QueryNode>();
|
||||
auto * union_node = table_expression_node->as<UnionNode>();
|
||||
bool is_cte = (query_node && query_node->isCTE()) || (union_node && union_node->isCTE());
|
||||
|
||||
if (!is_cte && table_expression_node->hasAlias())
|
||||
if (table_expression_node->hasAlias())
|
||||
additional_column_qualification_parts = {table_expression_node->getAlias()};
|
||||
else if (auto * table_node = table_expression_node->as<TableNode>())
|
||||
additional_column_qualification_parts = {table_node->getStorageID().getDatabaseName(), table_node->getStorageID().getTableName()};
|
||||
else if (auto * query_node = table_expression_node->as<QueryNode>(); query_node && query_node->isCTE())
|
||||
additional_column_qualification_parts = {"", query_node->getCTEName()};
|
||||
else if (auto * union_node = table_expression_node->as<UnionNode>(); union_node && union_node->isCTE())
|
||||
additional_column_qualification_parts = {"", union_node->getCTEName()};
|
||||
|
||||
size_t additional_column_qualification_parts_size = additional_column_qualification_parts.size();
|
||||
const auto & table_expression_data = scope.getTableExpressionDataOrThrow(table_expression_node);
|
||||
|
@ -448,13 +448,13 @@ SELECT '--';
|
||||
DESCRIBE (WITH test_table_in_cte_1 AS (SELECT 1 AS c1), test_table_in_cte_2 AS (SELECT 1 AS c1) SELECT *
|
||||
FROM test_table_in_cte_1 INNER JOIN test_table_in_cte_2 as test_table_in_cte_2 ON test_table_in_cte_1.c1 = test_table_in_cte_2.c1);
|
||||
c1 UInt8
|
||||
c1 UInt8
|
||||
test_table_in_cte_2.c1 UInt8
|
||||
SELECT '--';
|
||||
--
|
||||
DESCRIBE (WITH test_table_in_cte_1 AS (SELECT 1 AS c1), test_table_in_cte_2 AS (SELECT 1 AS c1 UNION ALL SELECT 1 AS c1) SELECT *
|
||||
FROM test_table_in_cte_1 INNER JOIN test_table_in_cte_2 as test_table_in_cte_2 ON test_table_in_cte_1.c1 = test_table_in_cte_2.c1);
|
||||
c1 UInt8
|
||||
c1 UInt8
|
||||
test_table_in_cte_2.c1 UInt8
|
||||
SELECT 'Joins';
|
||||
Joins
|
||||
DESCRIBE (SELECT * FROM test_table_join_1, test_table_join_2);
|
||||
|
@ -20,7 +20,7 @@ WITH
|
||||
SELECT toInt64(number) AS a
|
||||
FROM numbers(10)
|
||||
)
|
||||
SELECT a.a, b, b.a, c.a
|
||||
SELECT *
|
||||
FROM dist_t0 AS a
|
||||
LEFT JOIN b AS b ON a.a = b.a
|
||||
LEFT JOIN c AS c ON a.a = c.a
|
||||
|
Loading…
Reference in New Issue
Block a user