Cleanup and add test

This commit is contained in:
Dmitry Novik 2024-05-16 16:49:28 +02:00
parent e4eaf256b1
commit d5b6903393
2 changed files with 6 additions and 2 deletions

View File

@ -4623,12 +4623,14 @@ QueryAnalyzer::QueryTreeNodesWithNames QueryAnalyzer::resolveUnqualifiedMatcher(
"Unknown identifier '{}' inside COLUMNS matcher. In scope {}",
identifier.getFullName(), scope.dump());
// TODO: Introduce IdentifierLookupContext::COLUMN and get read of this check
// TODO: Introduce IdentifierLookupContext::COLUMN and get rid of this check
auto * resolved_column = resolve_result.resolved_identifier->as<ColumnNode>();
if (!resolved_column)
throw Exception(ErrorCodes::UNKNOWN_IDENTIFIER,
"Identifier '{}' inside COLUMNS matcher must resolve into a column, but got {}. In scope {}",
identifier.getFullName(), resolve_result.resolved_identifier->getNodeTypeName(), scope.dump());
identifier.getFullName(),
resolve_result.resolved_identifier->getNodeTypeName(),
scope.scope_node->formatASTForErrorMessage());
result.emplace_back(resolve_result.resolved_identifier, resolved_column->getColumnName());
}
return result;

View File

@ -1 +1,3 @@
SELECT COLUMNS(license_text, library_name) APPLY (length) FROM system.licenses ORDER BY library_name LIMIT 1;
SELECT COLUMNS(license_text, library_name, xyz) APPLY (length) FROM system.licenses; -- { serverError UNKNOWN_IDENTIFIER }