【问题标题】:Clickhouse pass data for inner join内部连接的 Clickhouse 传递数据
【发布时间】:2021-09-09 06:46:28
【问题描述】:

在 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 中是否存在这种连接?如果是,应该怎么写?

【问题讨论】:

    标签: clickhouse


    【解决方案1】:

    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         │
    └────────────────┴───────────────┘
    

    【讨论】:

      猜你喜欢
      • 2022-08-04
      • 1970-01-01
      • 1970-01-01
      • 2016-06-12
      • 2018-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多