Backport #70264 to 24.8: Fix segfault on creating materialized view with intersect

This commit is contained in:
robot-clickhouse 2024-10-14 10:09:30 +00:00
parent 457606b598
commit b0a8d7fc7b
3 changed files with 9 additions and 5 deletions

View File

@ -100,17 +100,20 @@ void checkAllowedQueries(const ASTSelectQuery & query)
/// check if only one single select query in SelectWithUnionQuery
static bool isSingleSelect(const ASTPtr & select, ASTPtr & res)
{
auto new_select = select->as<ASTSelectWithUnionQuery &>();
if (new_select.list_of_selects->children.size() != 1)
auto * new_select = select->as<ASTSelectWithUnionQuery>();
if (new_select == nullptr)
return false;
auto & new_inner_query = new_select.list_of_selects->children.at(0);
if (new_select->list_of_selects->children.size() != 1)
return false;
auto & new_inner_query = new_select->list_of_selects->children.at(0);
if (new_inner_query->as<ASTSelectQuery>())
{
res = new_inner_query;
return true;
}
else
return isSingleSelect(new_inner_query, res);
return isSingleSelect(new_inner_query, res);
}
SelectQueryDescription SelectQueryDescription::getSelectQueryFromASTForMatView(const ASTPtr & select, bool refreshable, ContextPtr context)

View File

@ -0,0 +1 @@
CREATE MATERIALIZED VIEW v0 AS (SELECT 1) INTERSECT (SELECT 1); --{serverError QUERY_IS_NOT_SUPPORTED_IN_MATERIALIZED_VIEW}