https://stackoverflow.com/questions/70447927/h2-seems-to-misinterpret-a-valid-join-clause
https://groups.google.com/g/h2-database/c/46iO3_XBwlA
Reduced test case:
CREATE TABLE T1(C1 INTEGER) AS VALUES 1, 2, 4;
CREATE TABLE T2(C2 INTEGER) AS VALUES 1, 3, 4;
CREATE TABLE T3(C3 INTEGER) AS VALUES 2, 3, 4;
SELECT * FROM T1 JOIN T2 LEFT JOIN T3 ON T2.C2 = T3.C3 ON T1.C1 = T2.C2;
This query should return
but it throws Column "T2.C2" not found.
Due to the same bug some invalid join conditions are accepted:
SELECT * FROM T A JOIN T B LEFT JOIN T C ON C.COL = A.COL;
I already wrote a fix, but some test cases need adjustments, because inner joins can be recomposed by H2 in different ways.