mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Fix multiple column transformers.
This commit is contained in:
parent
ca6e56f997
commit
8eb8175258
@ -228,6 +228,7 @@ void TranslateQualifiedNamesMatcher::visit(ASTExpressionList & node, const ASTPt
|
|||||||
|
|
||||||
for (const auto & child : old_children)
|
for (const auto & child : old_children)
|
||||||
{
|
{
|
||||||
|
ASTs columns;
|
||||||
if (const auto * asterisk = child->as<ASTAsterisk>())
|
if (const auto * asterisk = child->as<ASTAsterisk>())
|
||||||
{
|
{
|
||||||
bool first_table = true;
|
bool first_table = true;
|
||||||
@ -237,7 +238,7 @@ void TranslateQualifiedNamesMatcher::visit(ASTExpressionList & node, const ASTPt
|
|||||||
{
|
{
|
||||||
if (first_table || !data.join_using_columns.count(column.name))
|
if (first_table || !data.join_using_columns.count(column.name))
|
||||||
{
|
{
|
||||||
addIdentifier(node.children, table.table, column.name, AsteriskSemantic::getAliases(*asterisk));
|
addIdentifier(columns, table.table, column.name, AsteriskSemantic::getAliases(*asterisk));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +246,7 @@ void TranslateQualifiedNamesMatcher::visit(ASTExpressionList & node, const ASTPt
|
|||||||
}
|
}
|
||||||
for (const auto & transformer : asterisk->children)
|
for (const auto & transformer : asterisk->children)
|
||||||
{
|
{
|
||||||
IASTColumnsTransformer::transform(transformer, node.children);
|
IASTColumnsTransformer::transform(transformer, columns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (const auto * asterisk_pattern = child->as<ASTColumnsMatcher>())
|
else if (const auto * asterisk_pattern = child->as<ASTColumnsMatcher>())
|
||||||
@ -253,7 +254,7 @@ void TranslateQualifiedNamesMatcher::visit(ASTExpressionList & node, const ASTPt
|
|||||||
if (asterisk_pattern->column_list)
|
if (asterisk_pattern->column_list)
|
||||||
{
|
{
|
||||||
for (const auto & ident : asterisk_pattern->column_list->children)
|
for (const auto & ident : asterisk_pattern->column_list->children)
|
||||||
node.children.emplace_back(ident->clone());
|
columns.emplace_back(ident->clone());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -264,7 +265,7 @@ void TranslateQualifiedNamesMatcher::visit(ASTExpressionList & node, const ASTPt
|
|||||||
{
|
{
|
||||||
if (asterisk_pattern->isColumnMatching(column.name) && (first_table || !data.join_using_columns.count(column.name)))
|
if (asterisk_pattern->isColumnMatching(column.name) && (first_table || !data.join_using_columns.count(column.name)))
|
||||||
{
|
{
|
||||||
addIdentifier(node.children, table.table, column.name, AsteriskSemantic::getAliases(*asterisk_pattern));
|
addIdentifier(columns, table.table, column.name, AsteriskSemantic::getAliases(*asterisk_pattern));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +275,7 @@ void TranslateQualifiedNamesMatcher::visit(ASTExpressionList & node, const ASTPt
|
|||||||
// ColumnsMatcher's transformers start to appear at child 1
|
// ColumnsMatcher's transformers start to appear at child 1
|
||||||
for (auto it = asterisk_pattern->children.begin() + 1; it != asterisk_pattern->children.end(); ++it)
|
for (auto it = asterisk_pattern->children.begin() + 1; it != asterisk_pattern->children.end(); ++it)
|
||||||
{
|
{
|
||||||
IASTColumnsTransformer::transform(*it, node.children);
|
IASTColumnsTransformer::transform(*it, columns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (const auto * qualified_asterisk = child->as<ASTQualifiedAsterisk>())
|
else if (const auto * qualified_asterisk = child->as<ASTQualifiedAsterisk>())
|
||||||
@ -287,7 +288,7 @@ void TranslateQualifiedNamesMatcher::visit(ASTExpressionList & node, const ASTPt
|
|||||||
{
|
{
|
||||||
for (const auto & column : table.columns)
|
for (const auto & column : table.columns)
|
||||||
{
|
{
|
||||||
addIdentifier(node.children, table.table, column.name, AsteriskSemantic::getAliases(*qualified_asterisk));
|
addIdentifier(columns, table.table, column.name, AsteriskSemantic::getAliases(*qualified_asterisk));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -295,11 +296,16 @@ void TranslateQualifiedNamesMatcher::visit(ASTExpressionList & node, const ASTPt
|
|||||||
// QualifiedAsterisk's transformers start to appear at child 1
|
// QualifiedAsterisk's transformers start to appear at child 1
|
||||||
for (auto it = qualified_asterisk->children.begin() + 1; it != qualified_asterisk->children.end(); ++it)
|
for (auto it = qualified_asterisk->children.begin() + 1; it != qualified_asterisk->children.end(); ++it)
|
||||||
{
|
{
|
||||||
IASTColumnsTransformer::transform(*it, node.children);
|
IASTColumnsTransformer::transform(*it, columns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
node.children.emplace_back(child);
|
columns.emplace_back(child);
|
||||||
|
|
||||||
|
node.children.insert(
|
||||||
|
node.children.end(),
|
||||||
|
std::make_move_iterator(columns.begin()),
|
||||||
|
std::make_move_iterator(columns.end()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,10 @@ void ASTColumnsMatcher::formatImpl(const FormatSettings & settings, FormatState
|
|||||||
{
|
{
|
||||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << "COLUMNS" << (settings.hilite ? hilite_none : "") << "(";
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << "COLUMNS" << (settings.hilite ? hilite_none : "") << "(";
|
||||||
if (column_list)
|
if (column_list)
|
||||||
|
{
|
||||||
|
frame.expression_list_prepend_whitespace = false;
|
||||||
column_list->formatImpl(settings, state, frame);
|
column_list->formatImpl(settings, state, frame);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
settings.ostr << quoteString(original_pattern);
|
settings.ostr << quoteString(original_pattern);
|
||||||
settings.ostr << ")";
|
settings.ostr << ")";
|
||||||
|
@ -67,3 +67,13 @@ SELECT
|
|||||||
sum(j),
|
sum(j),
|
||||||
sum(k)
|
sum(k)
|
||||||
FROM columns_transformers
|
FROM columns_transformers
|
||||||
|
100 10 100 10 324 10
|
||||||
|
120 8 120 8 23 8
|
||||||
|
SELECT
|
||||||
|
i,
|
||||||
|
j,
|
||||||
|
toFloat64(i),
|
||||||
|
toFloat64(j),
|
||||||
|
toFloat64(k),
|
||||||
|
j
|
||||||
|
FROM columns_transformers
|
||||||
|
@ -37,4 +37,8 @@ EXPLAIN SYNTAX SELECT * REPLACE(i + 1 AS i) REPLACE(i + 1 AS i) from columns_tra
|
|||||||
SELECT COLUMNS(i, j, k) APPLY(sum) from columns_transformers;
|
SELECT COLUMNS(i, j, k) APPLY(sum) from columns_transformers;
|
||||||
EXPLAIN SYNTAX SELECT COLUMNS(i, j, k) APPLY(sum) from columns_transformers;
|
EXPLAIN SYNTAX SELECT COLUMNS(i, j, k) APPLY(sum) from columns_transformers;
|
||||||
|
|
||||||
|
-- Multiple column matchers and transformers
|
||||||
|
SELECT i, j, COLUMNS(i, j, k) APPLY(toFloat64), COLUMNS(i, j) EXCEPT (i) from columns_transformers;
|
||||||
|
EXPLAIN SYNTAX SELECT i, j, COLUMNS(i, j, k) APPLY(toFloat64), COLUMNS(i, j) EXCEPT (i) from columns_transformers;
|
||||||
|
|
||||||
DROP TABLE columns_transformers;
|
DROP TABLE columns_transformers;
|
||||||
|
Loading…
Reference in New Issue
Block a user