This commit is contained in:
kssenii 2022-12-07 11:26:32 +01:00
parent 862da8f459
commit 3725cf4aa7

View File

@ -329,31 +329,27 @@ using ExistsExpressionVisitor = InDepthNodeVisitor<OneTypeMatcher<ExistsExpressi
struct ReplacePositionalArgumentsData
{
using TypeToVisit = ASTSelectQuery;
ContextPtr context;
void visit(ASTSelectQuery & select_query, ASTPtr &) const
static void visit(ASTSelectQuery & select_query, ASTPtr &)
{
if (context->getSettingsRef().enable_positional_arguments)
if (select_query.groupBy())
{
if (select_query.groupBy())
for (auto & expr : select_query.groupBy()->children)
replaceForPositionalArguments(expr, &select_query, ASTSelectQuery::Expression::GROUP_BY);
}
if (select_query.orderBy())
{
for (auto & expr : select_query.orderBy()->children)
{
for (auto & expr : select_query.groupBy()->children)
replaceForPositionalArguments(expr, &select_query, ASTSelectQuery::Expression::GROUP_BY);
}
if (select_query.orderBy())
{
for (auto & expr : select_query.orderBy()->children)
{
auto & elem = assert_cast<ASTOrderByElement &>(*expr).children.at(0);
replaceForPositionalArguments(elem, &select_query, ASTSelectQuery::Expression::ORDER_BY);
}
}
if (select_query.limitBy())
{
for (auto & expr : select_query.limitBy()->children)
replaceForPositionalArguments(expr, &select_query, ASTSelectQuery::Expression::LIMIT_BY);
auto & elem = assert_cast<ASTOrderByElement &>(*expr).children.at(0);
replaceForPositionalArguments(elem, &select_query, ASTSelectQuery::Expression::ORDER_BY);
}
}
if (select_query.limitBy())
{
for (auto & expr : select_query.limitBy()->children)
replaceForPositionalArguments(expr, &select_query, ASTSelectQuery::Expression::LIMIT_BY);
}
}
};
@ -1508,8 +1504,11 @@ void TreeRewriter::normalize(
ExistsExpressionVisitor::Data exists;
ExistsExpressionVisitor(exists).visit(query);
ReplacePositionalArgumentsVisitor::Data data_replace_positional_arguments{context_};
ReplacePositionalArgumentsVisitor(data_replace_positional_arguments).visit(query);
if (context_->getSettingsRef().enable_positional_arguments)
{
ReplacePositionalArgumentsVisitor::Data data_replace_positional_arguments;
ReplacePositionalArgumentsVisitor(data_replace_positional_arguments).visit(query);
}
if (settings.transform_null_in)
{