You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exception: Number of columns doesn't match while inserting with UNION ALL into AggregatingMergeTree table #8030
INSERT INTO test_table SELECT * FROM (
(SELECT 'ONE','OUT','79853108939','35338606180662','250016171930158','79853108939',sumState(toUInt32(1)),minState(toUInt64(1519851774000)),maxState(toUInt64(1519851774000)))
UNION ALL
(SELECT 'ONE','IN','79155050277','35915207655548','250016113029618','123456',sumState(toUInt32(1)),minState(toUInt64(1519851669000)),maxState(toUInt64(1519851669000))))
Though this works perfectly (the same request, but with different data - changed one field in the first row to SOME_OTHER_VALUE)
INSERT INTO test_table SELECT * FROM (
(SELECT 'ONE','OUT','79853108939','35338606180662','250016171930158','SOME_OTHER_VALUE',sumState(toUInt32(1)),minState(toUInt64(1519851774000)),maxState(toUInt64(1519851774000)))
UNION ALL
(SELECT 'ONE','IN','79155050277','35915207655548','250016113029618','123456',sumState(toUInt32(1)),minState(toUInt64(1519851669000)),maxState(toUInt64(1519851669000))))
ClickHouse server version 19.17.2
It happens in CLI and with Flink Connector
create table test_table
( x Int64,
cnt UInt32,
min_ts SimpleAggregateFunction(min, UInt64) Codec(LZ4),
max_ts SimpleAggregateFunction(max, UInt64) Codec(LZ4))
engine = AggregatingMergeTree() order by x;
insert into test_table values (1,1,1,1);
insert into test_table values (1,1,2,2);
optimize table test_table final;
select * from test_table;
┌─x─┬─cnt─┬─min_ts─┬─max_ts─┐
│ 1 │ 1 │ 1 │ 2 │
└───┴─────┴────────┴────────┘
input function
create table mv_z_store(a date, max_b AggregateFunction(MAX,Int64))
ENGINE = AggregatingMergeTree Partition by toYYYYMM(a) order by a;
INSERT INTO mv_z_store SELECT a, maxState(b) FROM input('a Date, b Int64') group by a format CSV "2019-12-05",1
INSERT INTO mv_z_store SELECT a, maxState(b) FROM input('a Date, b Int64') group by a format Values ('2019-12-05',1);
milovidov-desktop :) DESCRIBE (SELECT 1, 1 UNION ALL SELECT 1, 2)
DESCRIBE TABLE
(
SELECT
1,
1
UNION ALL
SELECT
1,
2
)
Query id: ce6051b7-9a51-4d3d-a4fd-39db75047958
Received exception from server (version 20.11.1):
Code: 44. DB::Exception: Received from localhost:9000. DB::Exception: Cannot add column 1: column with this name already exists.
Activity
den-crane commentedon Dec 6, 2019
Workarounds (copy from Telegram):
Insert through Null table https://gist.github.com/den-crane/f7382cd4f1f859ff6ac46afe7dc9925a
SimpleAggregateFunction
alexey-milovidov commentedon Nov 2, 2020
Close: #8030