forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
DROP TABLE IF EXISTS left;
DROP TABLE IF EXISTS right;
DROP TABLE IF EXISTS hybrid;
CREATE TABLE left (id Int32,value Int32,date_col Date,computed ALIAS value * 2)
ENGINE = MergeTree
PARTITION BY toYYYYMM(date_col)
ORDER BY (date_col, id);
INSERT INTO left VALUES (toInt32(2147483647),toInt32(2147483647),toDate('2149-06-06')),(toInt32(-2147483648),toInt32(-2147483648),toDate('1970-01-01')),(toInt32(0),toInt32(0),'1970-01-01'),(toInt32(1084637461),toInt32(1708739853),toDate(1335613783)),(toInt32(-221724287),toInt32(339886211),toDate(1294089763)),(toInt32(-1762862292),toInt32(-287306889),toDate(1375707465)),(toInt32(1169291374),toInt32(-1541024731),toDate(1082126480)),(toInt32(-1329695183),toInt32(-786819168),toDate(1226000164)),(toInt32(1899628504),toInt32(-370080625),toDate(1179050966)),(toInt32(550067609),toInt32(-1524000367),toDate(1410654931));
CREATE TABLE right (id Int32,value Int32,date_col Date,computed ALIAS value * 2)
ENGINE = MergeTree
PARTITION BY toYYYYMM(date_col)
ORDER BY (date_col, id);
INSERT INTO right VALUES (toInt32(2147483647),toInt32(2147483647),toDate('2149-06-06')),(toInt32(-2147483648),toInt32(-2147483648),toDate('1970-01-01')),(toInt32(0),toInt32(0),'1970-01-01'),(toInt32(1084637461),toInt32(1708739853),toDate(1335613783)),(toInt32(-221724287),toInt32(339886211),toDate(1294089763)),(toInt32(-1762862292),toInt32(-287306889),toDate(1375707465)),(toInt32(1169291374),toInt32(-1541024731),toDate(1082126480)),(toInt32(-1329695183),toInt32(-786819168),toDate(1226000164)),(toInt32(1899628504),toInt32(-370080625),toDate(1179050966)),(toInt32(550067609),toInt32(-1524000367),toDate(1410654931));
SET allow_experimental_hybrid_table=1;
CREATE TABLE hybrid (id Int32,value Int32,date_col Date,computed Int64)
ENGINE = Hybrid(remote('localhost', currentDatabase(), 'left'), date_col >= '2025-01-15', remote('localhost', currentDatabase(), 'right'), date_col < '2025-01-15');
SELECT max_computed FROM (SELECT max(computed) AS max_computed FROM hybrid);Also with sum:
SELECT max_computed FROM (SELECT max(computed) AS max_computed FROM hybrid);Code: 8. DB::Exception: Received from localhost:9000. DB::Exception: Cannot find column `max(__table1.computed)` in source stream, there are only columns: [max(__table2.computed)]. (THERE_IS_NO_COLUMN)
(query: SELECT max_computed FROM (SELECT max(computed) AS max_computed FROM hybrid)
)
Trace:
[clickhouse1] 2026.02.18 14:30:57.897071 [ 39 ] {1b8071f4-3d7e-47fa-bab1-08c9acd94aea} <Debug> executeQuery: (from 127.0.0.1:56782) (query 2, line 4) CREATE TABLE hybrid (id Int32,value Int32,date_col Date,computed Int64) ENGINE = Hybrid(remote('localhost', currentDatabase(), 'left'), date_col >= '2025-01-15', remote('localhost', currentDatabase(), 'right'), date_col < '2025-01-15'); (stage: Complete)
[clickhouse1] 2026.02.18 14:30:57.899097 [ 39 ] {1b8071f4-3d7e-47fa-bab1-08c9acd94aea} <Error> executeQuery: Code: 57. DB::Exception: Table default.hybrid already exists. (TABLE_ALREADY_EXISTS) (version 25.8.14.20001.altinityantalya (altinity build)) (from 127.0.0.1:56782) (query 2, line 4) (in query: CREATE TABLE hybrid (id Int32,value Int32,date_col Date,computed Int64) ENGINE = Hybrid(remote('localhost', currentDatabase(), 'left'), date_col >= '2025-01-15', remote('localhost', currentDatabase(), 'right'), date_col < '2025-01-15');), Stack trace (when copying this message, always include the lines below):
0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x0000000010eac2f0
1. DB::Exception::Exception(String&&, int, String, bool) @ 0x000000000b945a58
2. DB::Exception::Exception(PreformattedMessage&&, int) @ 0x000000000b945528
3. DB::Exception::Exception<String, String>(int, FormatStringHelperImpl<std::type_identity<String>::type, std::type_identity<String>::type>, String&&, String&&) @ 0x000000000b944f3c
4. DB::InterpreterCreateQuery::doCreateTable(DB::ASTCreateQuery&, DB::InterpreterCreateQuery::TableProperties const&, std::unique_ptr<DB::DDLGuard, std::default_delete<DB::DDLGuard>>&, DB::LoadingStrictnessLevel) @ 0x00000000151ec3a4
5. DB::InterpreterCreateQuery::createTable(DB::ASTCreateQuery&) @ 0x00000000151e16d4
6. DB::InterpreterCreateQuery::execute() @ 0x00000000151f1480
7. DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum, std::unique_ptr<DB::ReadBuffer, std::default_delete<DB::ReadBuffer>>&, std::shared_ptr<DB::IAST>&, std::shared_ptr<DB::ImplicitTransactionControlExecutor>) @ 0x00000000155a77c8
8. DB::executeQuery(String const&, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum) @ 0x00000000155a2c28
9. DB::TCPHandler::runImpl() @ 0x00000000169ac010
10. DB::TCPHandler::run() @ 0x00000000169c8a28
11. Poco::Net::TCPServerConnection::start() @ 0x000000001b4d1118
12. Poco::Net::TCPServerDispatcher::run() @ 0x000000001b4d16b4
13. Poco::PooledThread::run() @ 0x000000001b496fdc
14. Poco::ThreadImpl::runnableEntry(void*) @ 0x000000001b495350
15. ? @ 0x0000000000080398
16. ? @ 0x00000000000e9e9c
Reactions are currently unavailable