[CALCITE-7450] ValuesReduceRule incorrectly drops tuples when filter condition is irreducible#4846
Conversation
eaf324e to
715dd8f
Compare
ca59c54 to
b2e1f1d
Compare
|
@darpan-e6 As discussed in the email, we do not need to retain the email addresses of Claude's co-authors. |
I'd like to keep it if that's okay, Claude did help me write the test, and it feels right to acknowledge that. Happy to discuss if there's a policy reason to remove it though! Also, I haven't received any mail from you on this. |
You can check the Calcite mailing list; there's discussion about this there. |
Okay, makes sense. I will remove it. |
…condition is irreducible When the filter condition contains a UDF that cannot be reduced to a RexLiteral (e.g., no Janino CallImplementor), isAlwaysTrue() returns false for the unreduced RexCall, causing the rule to incorrectly drop the tuple. The fix checks whether the reduced value is a RexLiteral before evaluating isAlwaysTrue(); if it is not, the rule bails out and leaves the plan unchanged.
|
|
FYI: We have a whole framework in place for testing rules based on @darpan-e6 If you have some time to rework the test raise a new PR and ping me for review. |
|
Oh, my question, I forgot, sorry. |
|
I was not aware of it. Thanks @zabetak, I will do that. Allow me some time (like 4-5 hours). |



Summary
VALUEScannot be reduced toRexLiteralbyRexExecutorImpl,it returns the expression unchanged.ValuesReduceRule.apply()then callsisAlwaysTrue()on the unreducedRexCall, which returnsfalse, causing the rule to incorrectly drop the tuple.RexLiteralbefore evaluatingisAlwaysTrue(); if it is not reducible, the rule bails out and leaves the plan unchanged.Test plan
ValuesReduceRuleTestwith a RAND() function that cannot be reduced by Janino.PROJECT_FILTER_VALUES_MERGE— tuples are preserved.