-
Notifications
You must be signed in to change notification settings - Fork 8.3k
The database as parameter in the TO section is ignored when creating MATERIALIZED VIEW #39917
Description
The database in the TO section is ignored when creating MATERIALIZED VIEW:
CREATE MATERIALIZED VIEW {dbname:Identifier}.table_mv ON CLUSTER cluster TO {dbname:Identifier}.table always create MV with TO default.table.
But the query CREATE MATERIALIZED VIEW {dbname:Identifier}.table_mv ON CLUSTER cluster TO database_name.table works correctly.
How to reproduce
- CH: 22.3.7
- HTTP Interface
Create tables:
CREATE TABLE IF NOT EXISTS {dbname:Identifier}.some_table ON CLUSTER cluster (value String) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/{shard}/some_table', '{replica}') ORDER BY (value)
CREATE TABLE IF NOT EXISTS {dbname:Identifier}.test_trigger_table ON CLUSTER cluster (value String)ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/{shard}/test_trigger_table', '{replica}') ORDER BY (value)
Create MV:
CREATE MATERIALIZED VIEW IF NOT EXISTS {dbname:Identifier}.test_trigger_table_mv ON CLUSTER cluster TO {dbname:Identifier}.test_trigger_table AS SELECT value FROM {dbname:Identifier}.some_table
After execute query with --param_dbname=test, query SHOW CREATE test.test_trigger_table_mv returns
CREATE MATERIALIZED VIEW test.test_trigger_table_mv TO default.test_trigger_table (value String) AS SELECT value FROM test.some_table
Expected behavior
test.test_trigger_table_mv TO default.test_trigger_table => test.test_trigger_table_mv TO test.test_trigger_table