Skip to content

Instantly share code, notes, and snippets.

@den-crane
Created March 10, 2019 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save den-crane/005633470c70877dd28c00211cd9fcfb to your computer and use it in GitHub Desktop.
Save den-crane/005633470c70877dd28c00211cd9fcfb to your computer and use it in GitHub Desktop.
MV union all workaround
create table tableA (A String) Engine=MergeTree order by tuple();
create table tableB (B String) Engine=MergeTree order by tuple();
create table tableC (C String) Engine=Null;
create table storeABC(ABC String) Engine=MergeTree order by tuple();
create materialized view MVA to storeABC as select A ABC from tableA;
create materialized view MVB to storeABC as select B ABC from tableB;
create materialized view MVC to storeABC as select C ABC from tableC;
insert into tableA values('A');
insert into tableB values('B');
insert into tableC values('C');
select * from storeABC;
┌─ABC─┐
│ A │
│ B │
│ C │
└─────┘
select * from MVC; (the same store storeABC -> the same result)
┌─ABC─┐
│ A │
│ B │
│ C │
└─────┘
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment