mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 04:52:10 +00:00
errors fix
This commit is contained in:
parent
d1f00b5b22
commit
f656a6d799
@ -6791,13 +6791,13 @@ void QueryAnalyzer::checkDuplicateTableNamesOrAlias(QueryTreeNodePtr & join_node
|
||||
column_names.push_back(name_and_type.name);
|
||||
|
||||
if (column_names.empty())
|
||||
return;
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Names of projection columns cannot be empty");
|
||||
|
||||
std::sort(column_names.begin(), column_names.end());
|
||||
for (size_t i = 0; i < column_names.size() - 1; i++) // Check if there is not any duplicates because it will lead to broken result
|
||||
if (column_names[i] == column_names[i+1])
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS,
|
||||
"Name of columns and aliases should be unique for this query (you can add alias that will be different)"
|
||||
"Name of columns and aliases should be unique for this query (you can add/change aliases so they will not be duplicated)"
|
||||
"While processing '{}'", join_node->formatASTForErrorMessage());
|
||||
}
|
||||
|
||||
@ -6812,7 +6812,8 @@ void QueryAnalyzer::resolveJoin(QueryTreeNodePtr & join_node, IdentifierResolveS
|
||||
resolveQueryJoinTreeNode(join_node_typed.getRightTableExpression(), scope, expressions_visitor);
|
||||
validateJoinTableExpressionWithoutAlias(join_node, join_node_typed.getRightTableExpression(), scope);
|
||||
|
||||
checkDuplicateTableNamesOrAlias(join_node, join_node_typed.getLeftTableExpression(), join_node_typed.getRightTableExpression());
|
||||
if (!join_node_typed.getLeftTableExpression()->hasAlias() && !join_node_typed.getRightTableExpression()->hasAlias())
|
||||
checkDuplicateTableNamesOrAlias(join_node, join_node_typed.getLeftTableExpression(), join_node_typed.getRightTableExpression());
|
||||
|
||||
if (join_node_typed.isOnJoinExpression())
|
||||
{
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <Storages/StorageDictionary.h>
|
||||
#include <Storages/StorageJoin.h>
|
||||
#include <Storages/StorageValues.h>
|
||||
#include "Common/Exception.h"
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -267,13 +268,13 @@ bool JoinedTables::resolveTables()
|
||||
for (auto & name : t.columns.getNames())
|
||||
column_names.push_back(name);
|
||||
if (column_names.empty())
|
||||
return false;
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Names of joining columns cannot be empty");
|
||||
|
||||
std::sort(column_names.begin(), column_names.end());
|
||||
for (size_t i = 0; i < column_names.size() - 1; i++) // Check if there is not any duplicates because it will lead to broken result
|
||||
if (column_names[i] == column_names[i+1])
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS,
|
||||
"Name of columns and aliases should be unique for this query (you can add alias that will be different)"
|
||||
"Name of columns and aliases should be unique for this query (you can add/change aliases so they will not be duplicated)"
|
||||
"While processing '{}'", table_expressions[i]->formatForErrorMessage());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user