用于内部连接的 Clickhouse 传递数据

Clickhouse pass data for inner join

在 PostgreSQL 中,我们可以使用自定义数据连接表。

例如:

select * 
from points p 
inner join (VALUES (5, '2000-1-1'::date, 1, 1)) as x(id, create_date, store_id, supplier_id)
on p.id = x.id

Clickhouse中有这样的join吗?如果是,应该怎么写?

https://github.com/ClickHouse/ClickHouse/issues/5984

SELECT *
FROM VALUES('a UInt64, s String', (1, 'one'), (2, 'two'), (3, 'three'))

┌─a─┬─s─────┐
│ 1 │ one   │
│ 2 │ two   │
│ 3 │ three │
└───┴───────┘

WITH 
    [(toUInt64(1), 'one'), (2, 'two'), (3, 'three')] AS rows_array, 
    arrayJoin(rows_array) AS row_tuple
SELECT 
    row_tuple.1 AS number_decimal, 
    row_tuple.2 AS number_string
┌─number_decimal─┬─number_string─┐
│              1 │ one           │
│              2 │ two           │
│              3 │ three         │
└────────────────┴───────────────┘