Affects Version/s: None
Fix Version/s: 1.7.0
Incorrect rowType of correlate variable when correlated sub-query has its left relation as a join.
While executing this query with option "forceDecorrelate=false", I got a RuntimeException:
The plan was:
Debugging this case, I found that $cor0.SUPPLIER_ID was referencing to the 6th (index=5) of the correlating variable. And meanwhile the correlating variable has the same RelDataType as table "items" but not the left relation ("orders" join "items") of the rel Correlate.
After switching the join tables of the left relation, the query gave the right result. I think the reason was that the leading part (all that matters to RexFieldAccess "$cor0.SUPPLIER_ID") was now the same between table "items" and the left relation ("items" join "orders") of the rel Correlate.
With de-correlation, the first query also failed because the join condition was referencing to the wrong position. The second query succeed with de-correlation too.