mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #35691 from Avogar/fix-matview
Fix creating materialized view with subquery after server restart
This commit is contained in:
commit
771f34d793
@ -6,6 +6,7 @@
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <Interpreters/Context.h>
|
||||
#include <Interpreters/InterpreterCreateQuery.h>
|
||||
#include <Interpreters/ApplyWithSubqueryVisitor.h>
|
||||
#include <Parsers/ASTCreateQuery.h>
|
||||
#include <Parsers/ASTFunction.h>
|
||||
#include <Parsers/ParserCreateQuery.h>
|
||||
@ -55,6 +56,9 @@ std::pair<String, StoragePtr> createTableFromAST(
|
||||
ast_create_query.attach = true;
|
||||
ast_create_query.setDatabase(database_name);
|
||||
|
||||
if (ast_create_query.select && ast_create_query.isView())
|
||||
ApplyWithSubqueryVisitor().visit(*ast_create_query.select);
|
||||
|
||||
if (ast_create_query.as_table_function)
|
||||
{
|
||||
const auto & factory = TableFunctionFactory::instance();
|
||||
|
0
tests/integration/test_materialized_view_restart_server/__init__.py
Executable file
0
tests/integration/test_materialized_view_restart_server/__init__.py
Executable file
25
tests/integration/test_materialized_view_restart_server/test.py
Executable file
25
tests/integration/test_materialized_view_restart_server/test.py
Executable file
@ -0,0 +1,25 @@
|
||||
import pytest
|
||||
from helpers.cluster import ClickHouseCluster
|
||||
|
||||
cluster = ClickHouseCluster(__file__)
|
||||
node = cluster.add_instance("node", stay_alive=True)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def start_cluster():
|
||||
try:
|
||||
cluster.start()
|
||||
yield cluster
|
||||
finally:
|
||||
cluster.shutdown()
|
||||
|
||||
|
||||
def test_materialized_view_with_subquery(start_cluster):
|
||||
node.query("create table test (x UInt32) engine=TinyLog()")
|
||||
node.query(
|
||||
"create materialized view mv engine = TinyLog() as with subquery as (select * from test) select * from subquery"
|
||||
)
|
||||
node.restart_clickhouse(kill=True)
|
||||
node.query("insert into test select 1")
|
||||
result = node.query("select * from mv")
|
||||
assert int(result) == 1
|
Loading…
Reference in New Issue
Block a user