Skip to content

The database as parameter in the TO section is ignored when creating MATERIALIZED VIEW #39917

@tygygydyk

Description

@tygygydyk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateunexpected behaviourResult is unexpected, but not entirely wrong at the same time.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions