mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Modify except column transformer's error log
This commit is contained in:
parent
2b240029c1
commit
694ad1f452
@ -91,21 +91,21 @@ void ASTColumnsExceptTransformer::formatImpl(const FormatSettings & settings, Fo
|
||||
|
||||
void ASTColumnsExceptTransformer::transform(ASTs & nodes) const
|
||||
{
|
||||
ASTs expected_columns(children);
|
||||
std::set<String> expected_columns;
|
||||
for (size_t i = 0; i < children.size(); ++i)
|
||||
expected_columns.insert(children[i]->as<const ASTIdentifier &>().name());
|
||||
|
||||
for (auto it = nodes.begin(); it != nodes.end();)
|
||||
{
|
||||
bool removed = false;
|
||||
if (const auto * id = it->get()->as<ASTIdentifier>())
|
||||
{
|
||||
for (int i = expected_columns.size() - 1; i >= 0; --i)
|
||||
auto expected_column = expected_columns.find(id->shortName());
|
||||
if (expected_column != expected_columns.end())
|
||||
{
|
||||
if (expected_columns[i]->as<const ASTIdentifier &>().name() == id->shortName())
|
||||
{
|
||||
removed = true;
|
||||
expected_columns.erase(expected_columns.begin() + i);
|
||||
it = nodes.erase(it);
|
||||
}
|
||||
removed = true;
|
||||
expected_columns.erase(expected_column);
|
||||
it = nodes.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,15 +116,11 @@ void ASTColumnsExceptTransformer::transform(ASTs & nodes) const
|
||||
if (is_strict && !expected_columns.empty())
|
||||
{
|
||||
String expected_columns_str;
|
||||
for (size_t i = 0; i < expected_columns.size(); ++i)
|
||||
{
|
||||
if (i > 0)
|
||||
expected_columns_str += ", ";
|
||||
expected_columns_str += expected_columns[i]->as<const ASTIdentifier &>().name();
|
||||
}
|
||||
std::for_each(expected_columns.begin(), expected_columns.end(),
|
||||
[&](String x) { expected_columns_str += (" " + x) ; });
|
||||
|
||||
throw Exception(
|
||||
"Columns transformer EXCEPT expects following column(s) : " + expected_columns_str,
|
||||
"Columns transformer EXCEPT expects following column(s) :" + expected_columns_str,
|
||||
ErrorCodes::NO_SUCH_COLUMN_IN_TABLE);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,8 @@
|
||||
1970-04-11 1970-01-11 1970-11-21
|
||||
10 324
|
||||
8 23
|
||||
324
|
||||
23
|
||||
101 10 324
|
||||
121 8 23
|
||||
222 18 347
|
||||
|
@ -15,6 +15,7 @@ SELECT columns_transformers.* EXCEPT(j) APPLY(avg) from columns_transformers;
|
||||
SELECT a.* APPLY(toDate) EXCEPT(i, j) APPLY(any) from columns_transformers a;
|
||||
|
||||
SELECT * EXCEPT STRICT i from columns_transformers;
|
||||
SELECT * EXCEPT STRICT (i, j) from columns_transformers;
|
||||
SELECT * EXCEPT STRICT i, j1 from columns_transformers; -- { serverError 47 }
|
||||
SELECT * EXCEPT STRICT(i, j1) from columns_transformers; -- { serverError 16 }
|
||||
SELECT * REPLACE STRICT i + 1 AS i from columns_transformers;
|
||||
|
Loading…
Reference in New Issue
Block a user