mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Merge pull request #39850 from kitaisreal/select-query-has-join-method
Add hasJoin method into ASTSelectQuery
This commit is contained in:
commit
e6efb47aa3
@ -344,6 +344,25 @@ const ASTTablesInSelectQueryElement * ASTSelectQuery::join() const
|
||||
return getFirstTableJoin(*this);
|
||||
}
|
||||
|
||||
bool ASTSelectQuery::hasJoin() const
|
||||
{
|
||||
if (!tables())
|
||||
return false;
|
||||
|
||||
const auto & tables_in_select_query = tables()->as<ASTTablesInSelectQuery &>();
|
||||
if (tables_in_select_query.children.empty())
|
||||
return false;
|
||||
|
||||
for (const auto & child : tables_in_select_query.children)
|
||||
{
|
||||
const auto & tables_element = child->as<ASTTablesInSelectQueryElement &>();
|
||||
if (tables_element.table_join)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static String getTableExpressionAlias(const ASTTableExpression * table_expression)
|
||||
{
|
||||
if (table_expression->subquery)
|
||||
|
@ -131,6 +131,7 @@ public:
|
||||
std::pair<ASTPtr, bool> arrayJoinExpressionList() const;
|
||||
|
||||
const ASTTablesInSelectQueryElement * join() const;
|
||||
bool hasJoin() const;
|
||||
bool final() const;
|
||||
bool withFill() const;
|
||||
void replaceDatabaseAndTable(const String & database_name, const String & table_name);
|
||||
|
@ -5489,7 +5489,7 @@ std::optional<ProjectionCandidate> MergeTreeData::getQueryProcessingStageWithAgg
|
||||
// In order to properly analyze joins, aliases should be recognized. However, aliases get lost during projection analysis.
|
||||
// Let's disable projection if there are any JOIN clauses.
|
||||
// TODO: We need a better identifier resolution mechanism for projection analysis.
|
||||
if (select_query->join())
|
||||
if (select_query->hasJoin())
|
||||
return std::nullopt;
|
||||
|
||||
// INTERPOLATE expressions may include aliases, so aliases should be preserved
|
||||
|
Loading…
Reference in New Issue
Block a user