【发布时间】:2022-01-04 08:27:13
【问题描述】:
我试图在文档和其他论坛中找到答案,但未能理解。 文档:https://clickhouse.com/docs/en/sql-reference/statements/select/join/CH doc
我的表类似于:stack overflow question
我想在交易前获得订单价格(并返回订单 ts 和有关交易的信息)。
使用下面的代码,我得到以下错误:SQL 错误 [48]: ClickHouse 异常,代码:48,DB::Exception: ASOF join over right table Nullable column is not implemented
我尝试的是条件“IS NOT NULL”,但它没有做任何事情。
代码:
WITH
orders as(
SELECT order_timestamp, order_price, product_id
FROM order_table
WHERE
( order_timestamp >= toInt32(toDateTime64('2022-01-02 10:00:00.000', 3))*1000
AND order_timestamp <= toInt32(toDateTime64('2022-01-02 12:00:00.000', 3))*1000)
AND product_id = 'SPXFUT'
AND order_timestamp IS NOT NULL),
trades as (
SELECT
trade_timestamp,
price
FROM trades_table
WHERE
trade_timestamp >= toInt32(toDateTime64('2021-12-02 10:00:00.000', 3))*1000 AND trade_timestamp <= toInt32(toDateTime64('2021-12-02 12:00:00.000', 3))*1000
AND product_id = 'SPXFUT'
AND trade_timestamp IS NOT NULL),
results as(
SELECT
tt.product_id,
tt.trade_timestamp,
tt.price,
o.order_timestamp,
o.order_price
FROM trades tt
ASOF LEFT JOIN orders o
ON (tt.product_id = o.product_id ) AND (tt.trade_timestamp >= o.order_timestamp ))
SELECT *
FROM results
【问题讨论】:
标签: sql join clickhouse