ClickHouse报错-无法检测左右连接键
版本: 20.4.5
1.报错的原因
创建物化视图sql如下
CREATE MATERIALIZED VIEW sc_view ( id UInt8 , name String , age UInt8, class String ) ENGINE = MergeTree()
ORDER BY
(id) POPULATE AS
SELECT
s.id,
s.name,
s.age,
c.name As class
FROM
student
LEFT JOIN class ON s.id = c.id
ORDER BY
s.id ;
报错:
Cannot detect left and right JOIN keys. JOIN ON section is ambiguous
无法检测左右连接键。节上的连接是模糊的
原因:
这是目前CH的一个BUG,将sql语句改为以下的格式即可
CREATE MATERIALIZED VIEW sc_view ( id UInt8 , name String , age UInt8, class String ) ENGINE = MergeTree()
ORDER BY
(id) POPULATE AS
SELECT
student.id,
student.name,
student.age,
class.name As class
FROM
student
LEFT JOIN class ON student.id = class.id
ORDER BY
student.id ;