version 1.1.54383, version 1.1.54342
union all with constant from distributed table, throw exception
a minimal reproducible example
``` create table
CREATE TABLE datacenter.testunionalla_shard ON CLUSTER datacenter
(
a String
)
ENGINE = Log;
CREATE TABLE datacenter.testunionalla ON CLUSTER datacenter
(
a String
)
ENGINE = Distributed(datacenter, datacenter, testunionalla_shard, rand());
``` select
SELECT count()
FROM
(
SELECT
'aa' AS tt,
a
FROM datacenter.testunionalla
UNION ALL
SELECT
'aa' AS tt,
a
FROM datacenter.testunionalla
) ;
Received exception from server (version 1.1.54383):
Code: 171. DB::Exception: Received from clickhouse-server-test DB::Exception: Cannot convert column tt because it is non constant in source stream but must be constant in result.
select uid, if(toUInt8(uid), 's', 'v') as t from nxlog.table limit 10
union all
select uid, if(toUInt8(uid), 's', 'v') as s from nxlog.table limit 10
worked but stupid
It the datacenter cluster contains local shard?
@alexey-milovidov , yes.
the name of cluster is datacenter.
the name of database is datacenter too.
SELECT *
FROM system.clusters
ββclusterβββββ¬βshard_numββ¬βshard_weightββ¬βreplica_numββ¬βhost_nameβββββββ¬βportββ¬βis_localββ¬βuserβββββ¬βdefault_databaseββ
β datacenter β 1 β 1 β 1 β hadoop-180-111 β 9000 β 1 β default β β
β datacenter β 2 β 1 β 1 β hadoop-180-112 β 9000 β 0 β default β β
β datacenter β 3 β 1 β 1 β hadoop-180-113 β 9000 β 0 β default β β
β datacenter β 4 β 1 β 1 β hadoop-180-114 β 9000 β 0 β default β β
β datacenter β 5 β 1 β 1 β hadoop-180-115 β 9000 β 0 β default β β
ββββββββββββββ΄ββββββββββββ΄βββββββββββββββ΄ββββββββββββββ΄βββββββββββββββββ΄ββββββββββββββββ΄βββββββ΄βββββββββββ΄ββββββββββ΄βββββββββββββββββββ
Problem is still here.
Simple test case:
SELECT
'settings' AS source,
*
FROM system.settings
UNION ALL
SELECT
'settings' AS source,
*
FROM remote('127.0.0.1', 'system', 'settings')
Received exception from server (version 19.13.3):
Code: 171. DB::Exception: Received from localhost:9000. DB::Exception: Cannot convert column source because it is non constant in source stream but must be constant in result. Stack trace:
0. /usr/bin/clickhouse-server(StackTrace::StackTrace()+0x30) [0x7f6b5f0]
1. /usr/bin/clickhouse-server(DB::Exception::Exception(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)+0x25) [0x3c46865]
2. /usr/bin/clickhouse-server() [0x3a3ba35]
3. /usr/bin/clickhouse-server(DB::InterpreterSelectWithUnionQuery::executeWithMultipleStreams()+0x1aa) [0x6d8abda]
4. /usr/bin/clickhouse-server(DB::InterpreterSelectWithUnionQuery::execute()+0x38) [0x6d8c958]
5. /usr/bin/clickhouse-server() [0x6e98ff1]
6. /usr/bin/clickhouse-server(DB::executeQuery(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool)+0xfc) [0x6e9a14c]
7. /usr/bin/clickhouse-server(DB::TCPHandler::runImpl()+0x9fa) [0x3c87fba]
8. /usr/bin/clickhouse-server(DB::TCPHandler::run()+0x2b) [0x3c8887b]
9. /usr/bin/clickhouse-server(Poco::Net::TCPServerConnection::start()+0x10) [0x793f490]
10. /usr/bin/clickhouse-server(Poco::Net::TCPServerDispatcher::run()+0xed) [0x793fbad]
11. /usr/bin/clickhouse-server(Poco::PooledThread::run()+0x81) [0x806a4e1]
12. /usr/bin/clickhouse-server(Poco::ThreadImpl::runnableEntry(void*)+0x3c) [0x806828c]
13. /usr/bin/clickhouse-server() [0xba3e1a0]
14. /lib/x86_64-linux-gnu/libpthread.so.0(+0x76db) [0x7f409eebb6db]
15. /lib/x86_64-linux-gnu/libc.so.6(clone+0x3f) [0x7f409e64288f]
0 rows in set. Elapsed: 0.006 sec.
Workaround - is to use materialize function:
select 'settings' as source, * from system.settings union all select materialize('settings') as source, * from remote('127.0.0.1','system','settings') ;
Fixed in master.