mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Don't replace tables with compound names
This commit is contained in:
parent
7f130d2362
commit
e9849ba8de
@ -605,11 +605,12 @@ void replaceJoinedTable(const ASTTablesInSelectQueryElement* join)
|
|||||||
if (table_expr.database_and_table_name)
|
if (table_expr.database_and_table_name)
|
||||||
{
|
{
|
||||||
auto & table_id = typeid_cast<ASTIdentifier &>(*table_expr.database_and_table_name.get());
|
auto & table_id = typeid_cast<ASTIdentifier &>(*table_expr.database_and_table_name.get());
|
||||||
String expr = "(select * from " + table_id.name + ")";
|
String expr = "(select * from " + table_id.name + ") as " + table_id.shortName();
|
||||||
|
|
||||||
// FIXME: since the expression "a as b" exposes both "a" and "b" names, which is not equivalent to "(select * from a) as b",
|
// FIXME: since the expression "a as b" exposes both "a" and "b" names, which is not equivalent to "(select * from a) as b",
|
||||||
// we can't replace aliased tables.
|
// we can't replace aliased tables.
|
||||||
if (table_id.alias.empty())
|
// FIXME: long table names include database name, which we can't save within alias.
|
||||||
|
if (table_id.alias.empty() && table_id.isShort())
|
||||||
{
|
{
|
||||||
ParserTableExpression parser;
|
ParserTableExpression parser;
|
||||||
table_expr = static_cast<ASTTableExpression &>(*parseQuery(parser, expr, 0));
|
table_expr = static_cast<ASTTableExpression &>(*parseQuery(parser, expr, 0));
|
||||||
|
@ -43,7 +43,7 @@ SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n
|
|||||||
2000-01-01 1 test string 1 1
|
2000-01-01 1 test string 1 1
|
||||||
SELECT \n date, \n id, \n name, \n value, \n date, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n WHERE id = 1\n) \nANY LEFT JOIN \n(\n SELECT *\n FROM test.test \n WHERE id = 1\n) USING (id)\nWHERE id = 1
|
SELECT \n date, \n id, \n name, \n value, \n date, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test \n WHERE id = 1\n) \nANY LEFT JOIN \n(\n SELECT *\n FROM test.test \n WHERE id = 1\n) USING (id)\nWHERE id = 1
|
||||||
2000-01-01 1 test string 1 1 2000-01-01 test string 1 1
|
2000-01-01 1 test string 1 1 2000-01-01 test string 1 1
|
||||||
SELECT \n id, \n date, \n name, \n value\nFROM \n(\n SELECT toInt8(1) AS id\n) \nANY LEFT JOIN \n(\n SELECT *\n FROM test.test \n WHERE value = 1\n) USING (id)\nWHERE value = 1
|
SELECT \n id, \n date, \n name, \n value\nFROM \n(\n SELECT toInt8(1) AS id\n) \nANY LEFT JOIN \n(\n SELECT *\n FROM test.test \n WHERE value = 1\n) AS test USING (id)\nWHERE value = 1
|
||||||
1 2000-01-01 test string 1 1
|
1 2000-01-01 test string 1 1
|
||||||
SELECT b.value\nFROM \n(\n SELECT toInt8(1) AS id\n) \nANY LEFT JOIN test.test AS b USING (id)\nWHERE value = 1
|
SELECT b.value\nFROM \n(\n SELECT toInt8(1) AS id\n) \nANY LEFT JOIN test.test AS b USING (id)\nWHERE value = 1
|
||||||
1
|
1
|
||||||
|
Loading…
Reference in New Issue
Block a user