ClickHouse icon indicating copy to clipboard operation
ClickHouse copied to clipboard

default_temporary_table_engine = 'MergeTree' inherit keys when CREATE TEMPORARY TABLE ... AS ...

Open filimonov opened this issue 1 year ago • 3 comments

Use case

temporary tables used to prepare parts in some ETL process.

right now you CAN create another non-temporary table which will inerit / derive the ORDER BY & PARTITION BY from the original table.

create table test (a UInt8, b String, c Nullable(Float), date Date) Engine=MergeTree ORDER BY (a,b) PARTITION BY date;
CREATE TABLE test2 AS test; -- will have same engine, and keys as test

but you can't do the same with temporary table, when default_temporary_table_engine = 'MergeTree'

SET default_temporary_table_engine = 'MergeTree';
CREATE TEMPORARY TABLE test3 AS test; -- gives an exception NUMBER_OF_ARGUMENTS_DOESNT_MATCH requiring ORDER BY 

Describe the solution you'd like

Just derive the necessary engine parameters from the source table.

Describe alternatives you've considered

CREATE TEMPORARY TABLE test3 ORDER BY (a,b)  PARTITION BY date AS test;

That works but is not handy and error prone

filimonov avatar Feb 14 '24 21:02 filimonov

Lucky issue number! This looks easy to implement...

alexey-milovidov avatar Feb 15 '24 00:02 alexey-milovidov

I'd like to finish this lucky number.

xiedeyantu avatar Feb 17 '24 13:02 xiedeyantu

@xiedeyantu, thank you, this will be very appreciated!

alexey-milovidov avatar Feb 18 '24 00:02 alexey-milovidov

Any news from the lucky number issue ? @xiedeyantu @alexey-milovidov

aadant avatar Aug 16 '24 13:08 aadant