mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fix style error and test cases error
This commit is contained in:
parent
2c278f1e02
commit
28b981a76b
@ -80,6 +80,9 @@ void CollectJoinOnKeysMatcher::visit(const ASTFunction & func, const ASTPtr & as
|
||||
ASTPtr right = func.arguments->children.at(1);
|
||||
auto table_numbers = getTableNumbers(left, right, data);
|
||||
|
||||
if (table_numbers.first != table_numbers.second && table_numbers.first > 0 && table_numbers.second > 0)
|
||||
data.new_on_expression_valid = true;
|
||||
|
||||
/**
|
||||
* if this is an inner join and the expression related to less than 2 tables, then move it to WHERE
|
||||
*/
|
||||
@ -108,6 +111,9 @@ void CollectJoinOnKeysMatcher::visit(const ASTFunction & func, const ASTPtr & as
|
||||
ASTPtr right = func.arguments->children.at(1);
|
||||
auto table_numbers = getTableNumbers(left, right, data);
|
||||
|
||||
if (table_numbers.first != table_numbers.second && table_numbers.first > 0 && table_numbers.second > 0)
|
||||
data.new_on_expression_valid = true;
|
||||
|
||||
if (data.kind == ASTTableJoin::Kind::Inner
|
||||
&& (table_numbers.first == table_numbers.second || table_numbers.first == 0 || table_numbers.second == 0))
|
||||
{
|
||||
@ -116,7 +122,7 @@ void CollectJoinOnKeysMatcher::visit(const ASTFunction & func, const ASTPtr & as
|
||||
else
|
||||
data.new_where_conditions = makeASTFunction("and", data.new_where_conditions, ast->clone());
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -127,7 +133,7 @@ void CollectJoinOnKeysMatcher::visit(const ASTFunction & func, const ASTPtr & as
|
||||
|
||||
if (data.asof_left_key || data.asof_right_key)
|
||||
throw Exception("ASOF JOIN expects exactly one inequality in ON section. Unexpected '" + queryToString(ast) + "'",
|
||||
ErrorCodes::INVALID_JOIN_ON_EXPRESSION);
|
||||
ErrorCodes::INVALID_JOIN_ON_EXPRESSION);
|
||||
|
||||
ASTPtr left = func.arguments->children.at(0);
|
||||
ASTPtr right = func.arguments->children.at(1);
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
ASTPtr new_on_expression{};
|
||||
ASTPtr new_where_conditions{};
|
||||
bool has_some{false};
|
||||
bool new_on_expression_valid{false};
|
||||
|
||||
void addJoinKeys(const ASTPtr & left_ast, const ASTPtr & right_ast, const std::pair<size_t, size_t> & table_no);
|
||||
void addAsofJoinKeys(const ASTPtr & left_ast, const ASTPtr & right_ast, const std::pair<size_t, size_t> & table_no,
|
||||
|
@ -425,6 +425,9 @@ void collectJoinedColumns(TableJoin & analyzed_join, const ASTSelectQuery & sele
|
||||
ErrorCodes::INVALID_JOIN_ON_EXPRESSION);
|
||||
if (is_asof)
|
||||
data.asofToJoinKeys();
|
||||
else if (!data.new_on_expression_valid)
|
||||
throw Exception("JOIN expects left and right joined keys from two joined table in ON section. Unexpected '" + queryToString(data.new_on_expression) + "'",
|
||||
ErrorCodes::INVALID_JOIN_ON_EXPRESSION);
|
||||
else if (data.new_where_conditions != nullptr)
|
||||
{
|
||||
table_join.on_expression = data.new_on_expression;
|
||||
|
@ -23,6 +23,7 @@ join_use_nulls = 1
|
||||
-
|
||||
\N \N
|
||||
-
|
||||
1 1 \N \N
|
||||
2 2 \N \N
|
||||
-
|
||||
1 1 1 1
|
||||
@ -50,6 +51,7 @@ join_use_nulls = 0
|
||||
-
|
||||
-
|
||||
-
|
||||
1 1 0 0
|
||||
2 2 0 0
|
||||
-
|
||||
1 1 1 1
|
||||
|
Loading…
Reference in New Issue
Block a user