Merge pull request #1984 from zhang2014/fix/subquery_in_create

Fix exist subquery when create materializer view
This commit is contained in:
alexey-milovidov 2018-03-02 04:28:58 +03:00 committed by GitHub
commit 7e139866d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,9 +44,14 @@ static void extractDependentTable(const ASTSelectQuery & query, String & select_
select_database_name = typeid_cast<const ASTIdentifier &>(*query_database).name;
select_table_name = ast_id->name;
}
else if (auto ast_select = typeid_cast<const ASTSelectQuery *>(query_table.get()))
else if (auto ast_select = typeid_cast<const ASTSelectWithUnionQuery *>(query_table.get()))
{
extractDependentTable(*ast_select, select_database_name, select_table_name);
if (ast_select->list_of_selects->children.size() != 1)
throw Exception("UNION is not supported for MATERIALIZED VIEW", ErrorCodes::INCORRECT_QUERY);
auto inner_query = ast_select->list_of_selects->children.at(0);
extractDependentTable(typeid_cast<const ASTSelectQuery &>(*inner_query), select_database_name, select_table_name);
}
else
throw Exception("Logical error while creating StorageMaterializedView."