Skip to content

Insert into table with "MATERIALIZED VIEW" failed #2282

@henyihanwobushi

Description

@henyihanwobushi

I create a materialized view view_foo_bar on two table foo, bar then I can't insert into the table bar any more.

:) create table foo (ddate Date, id Int64, n String) ENGINE = ReplacingMergeTree(ddate, (id), 8192);

CREATE TABLE foo
(
    ddate Date,
    id Int64,
    n String
)
ENGINE = ReplacingMergeTree(ddate, id, 8192)

Ok.

0 rows in set. Elapsed: 0.003 sec.

:) create table bar (ddate Date, id Int64, n String, foo_id Int64) ENGINE = ReplacingMergeTree(ddate, (id), 8192);

CREATE TABLE bar
(
    ddate Date,
    id Int64,
    n String,
    foo_id Int64
)
ENGINE = ReplacingMergeTree(ddate, id, 8192)

Ok.

0 rows in set. Elapsed: 0.003 sec.

:) insert into bar (id, n, foo_id) values (1, 'bar_n_1', 1);

INSERT INTO bar (id, n, foo_id) VALUES

Ok.

1 rows in set. Elapsed: 0.001 sec.

:) create MATERIALIZED view view_foo_bar ENGINE = ReplacingMergeTree(ddate, (bar_id), 8192) as select ddate, bar_id, bar_n, foo_id, foo_n from (select ddate, id as bar_id, n as bar_n, foo_id from bar) any left join (select id as foo_id, n as foo_n from foo) using foo_id;

CREATE MATERIALIZED VIEW view_foo_bar
ENGINE = ReplacingMergeTree(ddate, bar_id, 8192) AS
SELECT
    ddate,
    bar_id,
    bar_n,
    foo_id,
    foo_n
FROM
(
    SELECT
        ddate,
        id AS bar_id,
        n AS bar_n,
        foo_id
    FROM bar
)
ANY LEFT JOIN
(
    SELECT
        id AS foo_id,
        n AS foo_n
    FROM foo
) USING (foo_id)

Ok.

0 rows in set. Elapsed: 0.006 sec.

:) insert into bar (id, n, foo_id) values (1, 'bar_n_1', 1);

INSERT INTO bar (id, n, foo_id) VALUES

Received exception from server (version 1.1.54370):
Code: 47. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Unknown identifier: bar_n: while pushing to view default.view_foo_bar.

1 rows in set. Elapsed: 0.081 sec.

Metadata

Metadata

Assignees

Labels

comp-materialized-viewMaterialized views: insert-triggered MV pipeline, insert dependencies, deduplication.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions