When the query contains multiple IN/SOME sub-queries connected with OR predicate in WHERE clause, the result is wrong. The minimal reproducer is below:
The Plan generated by calcite master branch: (Notice the bold part of <>($2, 0) in the downstream LogicalFilter)
The wrong part is that when build the downstream LogicalFilter for the two sub-queries, the filter for the second sub-query is AND(<>($2, 0), IS NOT NULL($9), IS NOT NULL($1)), notice that $2 should be the second sub-query's intermediate table field ct.c(which field index is $6), but now the actual reference is the first sub-query's, this leads to wrong plan, and wrong result.
The root cause is that intermediate table alias is the same as the previous sub-query's, but when lookup intermediate table field, it always returns the previous one which is not belong to the current subquery.