mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Allow identifiers staring with numbers in multiple joins
This commit is contained in:
parent
d2b8d293b4
commit
042e61febf
@ -18,7 +18,7 @@
|
||||
#include <Parsers/parseQuery.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <Core/Defines.h>
|
||||
|
||||
#include <Common/StringUtils/StringUtils.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -524,7 +524,8 @@ std::vector<TableNeededColumns> normalizeColumnNamesExtractNeeded(
|
||||
|
||||
size_t count = countTablesWithColumn(tables, short_name);
|
||||
|
||||
if (count > 1 || aliases.count(short_name))
|
||||
/// isValidIdentifierBegin retuired to be consistent with TableJoin::deduplicateAndQualifyColumnNames
|
||||
if (count > 1 || aliases.count(short_name) || !isValidIdentifierBegin(short_name.at(0)))
|
||||
{
|
||||
const auto & table = tables[*table_pos];
|
||||
IdentifierSemantic::setColumnLongName(*ident, table.table); /// table.column -> table_alias.column
|
||||
|
@ -1,2 +1,4 @@
|
||||
1 hello 1 world world 1
|
||||
2 hello 0 world 1
|
||||
1 321 1 123 123 1
|
||||
2 321 0 0 123 1
|
||||
|
@ -15,3 +15,21 @@ LEFT JOIN
|
||||
arrayJoin([1, 3]) AS k,
|
||||
'world'
|
||||
) AS t2 ON t1.k = t2.k;
|
||||
|
||||
SELECT
|
||||
t1.*,
|
||||
t2.*,
|
||||
123,
|
||||
isConstant('world')
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
arrayJoin([1, 2]) AS k,
|
||||
321
|
||||
) AS t1
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT
|
||||
arrayJoin([1, 3]) AS k,
|
||||
123
|
||||
) AS t2 ON t1.k = t2.k;
|
||||
|
@ -0,0 +1,2 @@
|
||||
1 1 1 1 1 1
|
||||
1
|
@ -0,0 +1,27 @@
|
||||
DROP TABLE IF EXISTS t1;
|
||||
DROP TABLE IF EXISTS t2;
|
||||
DROP TABLE IF EXISTS t3;
|
||||
|
||||
CREATE TABLE t1 ( `a1` Int64, `1a1` Int64 ) ENGINE = Memory;
|
||||
INSERT INTO t1 VALUES (1, 1);
|
||||
|
||||
CREATE TABLE t2 ( `b1` Int64, `1b1` Int64 ) ENGINE = Memory;
|
||||
INSERT INTO t2 VALUES (1, 1);
|
||||
|
||||
CREATE TABLE t3 ( `c1` Int64, `1c1` Int64 ) ENGINE = Memory;
|
||||
INSERT INTO t3 VALUES (1, 1);
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM t1 AS t1
|
||||
INNER JOIN t2 AS t2 ON t1.a1 = t2.b1
|
||||
INNER JOIN t3 AS t3 ON t1.a1 = t3.c1;
|
||||
|
||||
SELECT t2.`1b1` FROM t1 JOIN t2 ON a1 = b1;
|
||||
|
||||
-- Without quialification it doesn't work:
|
||||
-- SELECT `1b1` FROM t1 JOIN t2 ON a1 = b1;
|
||||
|
||||
DROP TABLE IF EXISTS t1;
|
||||
DROP TABLE IF EXISTS t2;
|
||||
DROP TABLE IF EXISTS t3;
|
Loading…
Reference in New Issue
Block a user