From a2dac6e2361ad124d71380db246ec29ffc9778d7 Mon Sep 17 00:00:00 2001 From: VadimPE Date: Mon, 17 Sep 2018 11:20:46 +0300 Subject: [PATCH 1/3] CLICKHOUSE-3993 add default type of JOIN --- dbms/src/Parsers/ParserTablesInSelectQuery.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dbms/src/Parsers/ParserTablesInSelectQuery.cpp b/dbms/src/Parsers/ParserTablesInSelectQuery.cpp index 6b28deeb227..1db7f458280 100644 --- a/dbms/src/Parsers/ParserTablesInSelectQuery.cpp +++ b/dbms/src/Parsers/ParserTablesInSelectQuery.cpp @@ -139,7 +139,7 @@ bool ParserTablesInSelectQueryElement::parseImpl(Pos & pos, ASTPtr & node, Expec if (ParserKeyword("INNER").ignore(pos)) table_join->kind = ASTTableJoin::Kind::Inner; - else if (ParserKeyword("LEFT").ignore(pos)) + if (ParserKeyword("LEFT").ignore(pos)) table_join->kind = ASTTableJoin::Kind::Left; else if (ParserKeyword("RIGHT").ignore(pos)) table_join->kind = ASTTableJoin::Kind::Right; @@ -149,8 +149,7 @@ bool ParserTablesInSelectQueryElement::parseImpl(Pos & pos, ASTPtr & node, Expec table_join->kind = ASTTableJoin::Kind::Cross; else { - /// Maybe need use INNER by default as in another DBMS. - return false; + table_join->kind = ASTTableJoin::Kind::Inner; } if (table_join->strictness != ASTTableJoin::Strictness::Unspecified From acf34e29ad85e53da9696358fe132971c2857f92 Mon Sep 17 00:00:00 2001 From: VadimPE Date: Mon, 17 Sep 2018 11:39:26 +0300 Subject: [PATCH 2/3] CLICKHOUSE-3993 add tests --- dbms/src/Parsers/ParserTablesInSelectQuery.cpp | 2 +- .../0_stateless/00717_default_join_type.reference | 1 + .../queries/0_stateless/00717_default_join_type.sql | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 dbms/tests/queries/0_stateless/00717_default_join_type.reference create mode 100644 dbms/tests/queries/0_stateless/00717_default_join_type.sql diff --git a/dbms/src/Parsers/ParserTablesInSelectQuery.cpp b/dbms/src/Parsers/ParserTablesInSelectQuery.cpp index 1db7f458280..16e1bdec302 100644 --- a/dbms/src/Parsers/ParserTablesInSelectQuery.cpp +++ b/dbms/src/Parsers/ParserTablesInSelectQuery.cpp @@ -139,7 +139,7 @@ bool ParserTablesInSelectQueryElement::parseImpl(Pos & pos, ASTPtr & node, Expec if (ParserKeyword("INNER").ignore(pos)) table_join->kind = ASTTableJoin::Kind::Inner; - if (ParserKeyword("LEFT").ignore(pos)) + else if (ParserKeyword("LEFT").ignore(pos)) table_join->kind = ASTTableJoin::Kind::Left; else if (ParserKeyword("RIGHT").ignore(pos)) table_join->kind = ASTTableJoin::Kind::Right; diff --git a/dbms/tests/queries/0_stateless/00717_default_join_type.reference b/dbms/tests/queries/0_stateless/00717_default_join_type.reference new file mode 100644 index 00000000000..7f6efad4038 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00717_default_join_type.reference @@ -0,0 +1 @@ +3 3 diff --git a/dbms/tests/queries/0_stateless/00717_default_join_type.sql b/dbms/tests/queries/0_stateless/00717_default_join_type.sql new file mode 100644 index 00000000000..4249790747c --- /dev/null +++ b/dbms/tests/queries/0_stateless/00717_default_join_type.sql @@ -0,0 +1,10 @@ +DROP TABLE IF EXISTS test.default_join1; +DROP TABLE IF EXISTS test.default_join2; + +CREATE TABLE test.default_join1(a Int64, b Int64) ENGINE=Memory; +CREATE TABLE test.default_join2(a Int64, b Int64) ENGINE=Memory; + +INSERT INTO test.default_join1 VALUES(1, 1), (2, 2), (3, 3); +INSERT INTO test.default_join2 VALUES(3, 3), (4, 4); + +SELECT a, b FROM test.default_join1 JOIN (SELECT a, b FROM test.default_join2) USING a ORDER BY b SETTINGS join_default_strictness='ANY'; From 3568087358c0a7502fdcd7001e9b0f9efb5e05c5 Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Mon, 17 Sep 2018 16:33:19 +0300 Subject: [PATCH 3/3] Update ParserTablesInSelectQuery.cpp --- dbms/src/Parsers/ParserTablesInSelectQuery.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dbms/src/Parsers/ParserTablesInSelectQuery.cpp b/dbms/src/Parsers/ParserTablesInSelectQuery.cpp index 16e1bdec302..4c300221db8 100644 --- a/dbms/src/Parsers/ParserTablesInSelectQuery.cpp +++ b/dbms/src/Parsers/ParserTablesInSelectQuery.cpp @@ -149,6 +149,7 @@ bool ParserTablesInSelectQueryElement::parseImpl(Pos & pos, ASTPtr & node, Expec table_join->kind = ASTTableJoin::Kind::Cross; else { + /// Use INNER by default as in another DBMS. table_join->kind = ASTTableJoin::Kind::Inner; }