Skip to content

[TASK] Fix Materialized Views being created in wrong ClickHouse database #34409

@erickgonzalez

Description

@erickgonzalez

Description

When initializing ClickHouse using the init.sql script, Materialized Views (MVs) are being created without an explicit database prefix and without a USE statement.

As a result:
• Tables are correctly created under clickhouse_test_db
• Materialized Views are created in the default database (usually default)
• Running SHOW TABLES; inside clickhouse_test_db does not list the MVs, causing confusion and operational issues

This behavior is due to ClickHouse defaulting to the current session database when the MV name is not fully qualified.

Acceptance Criteria

  • All Materialized Views are created under clickhouse_test_db
  • SHOW TABLES FROM clickhouse_test_db; lists all expected MVs
  • init.sql explicitly controls database context (via USE or fully qualified names)

Priority

Medium

Additional Context

  • Add USE clickhouse_test_db; after CREATE DATABASE IF NOT EXISTS
  • Fully Qualify MV names (e.g. clickhouse_test_db.content_events_counter_mv)

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions