我们试图将戊as 连接到ClickHouse,有时ClickHouse会生成这样的查询:
select
...
from
date_dimension_table,
fact_table,
other_dimension_table
where
fact_table.fact_date = date_dimension_table.date
and date_dimension_table.calendar_year = 2019
and date_dimension_table.month_name in ('April', 'June', ...)
and fact_table.other_dimension_id = other_dimension_table.id
and other_dimension_table.code in ('code1', 'code2', ...)
group by
date_dimension_table.calendar_year,
date_dimension_table.month_name,
other_dimension_table.code;它生成ClickHouse错误:代码: 403,e.displayText() =DB:::无效表达式用于连接。期望等于表达式,got (代码为c2) IN (‘code 1’,‘code 2’,.)。受支持的语法:联接ON Expr(table.column,.)= Expr(table.column,.) 和Expr([表.]列,.)=Expr([table.]列,.)
表用引擎: fact_table - MergeTree,双向- TinyLog.
因此,问题:
谢谢。
发布于 2020-04-23 13:26:44
此问题已从ClickHouse版本20.3.2.1,2020-03-12开始修复(请参阅第7314期),因此您需要升级CH。
好了!不要忘记检查所有向后不兼容的更改(请参阅变化量g)。
让我们在CH19.15.3修订版54426上重现此问题,以获得您所描述的错误:
Received exception from server (version 19.15.3):
Code: 403. DB::Exception: Received from localhost:9000. DB::Exception: Invalid expression for JOIN ON. Expected equals expression, got code IN ('code1', 'code2'). Supported syntax: JOIN ON Expr([table.]column, ...) = Expr([table.]column, ...) [AND Expr([table.]column, ...) = Expr([table.]column, ...) ...]. 现在,在最新版本CH (20.3.7修订版54433)上执行此查询,以确保它正确工作:
docker pull yandex/clickhouse-server:latest
docker run -d --name ch_test_latest yandex/clickhouse-server:latest
docker exec -it ch_test_latest clickhouse-client
# create tables as described below
..
# execute test query
..试验准备:
create table date_dimension_table (
date DateTime,
calendar_year Int32,
month_name String
) Engine = Memory;
create table fact_table (
fact_date DateTime,
other_dimension_id Int32
) Engine = Memory;
create table other_dimension_table (
id Int32,
code String
) Engine = Memory;测试查询:
SELECT
date_dimension_table.calendar_year,
date_dimension_table.month_name,
other_dimension_table.code
FROM date_dimension_table
,fact_table
,other_dimension_table
WHERE (fact_table.fact_date = date_dimension_table.date)
AND (date_dimension_table.calendar_year = 2019)
AND (date_dimension_table.month_name IN ('April', 'June'))
AND (fact_table.other_dimension_id = other_dimension_table.id)
AND (other_dimension_table.code IN ('code1', 'code2'))
GROUP BY
date_dimension_table.calendar_year,
date_dimension_table.month_name,
other_dimension_table.codehttps://stackoverflow.com/questions/61361818
复制相似问题