Search before asking
Version
master
What's Wrong?
Nereids FE constant folding unconditionally casts operands of ordered comparisons (>, >=, <, and <=) to ComparableLiteral after their children are folded.
Functions such as curtime() fold to TimeV2Literal, which extends Literal but does not implement ComparableLiteral. As a result, expressions such as curtime() >= '20:00:00' can fail during planning with ClassCastException.
What You Expected?
Ordered comparisons whose folded operands do not implement ComparableLiteral should remain as predicates for later evaluation instead of crashing during FE constant folding.
How to Reproduce?
Run a query containing an ordered comparison over curtime(), for example:
SELECT curtime() >= '20:00:00';
Proposed Fix
Guard ordered comparison folding by checking that both operands implement ComparableLiteral. Fold when both are comparable; otherwise preserve the rewritten comparison expression.
Search before asking
Version
master
What's Wrong?
Nereids FE constant folding unconditionally casts operands of ordered comparisons (
>,>=,<, and<=) toComparableLiteralafter their children are folded.Functions such as
curtime()fold toTimeV2Literal, which extendsLiteralbut does not implementComparableLiteral. As a result, expressions such ascurtime() >= '20:00:00'can fail during planning withClassCastException.What You Expected?
Ordered comparisons whose folded operands do not implement
ComparableLiteralshould remain as predicates for later evaluation instead of crashing during FE constant folding.How to Reproduce?
Run a query containing an ordered comparison over
curtime(), for example:Proposed Fix
Guard ordered comparison folding by checking that both operands implement
ComparableLiteral. Fold when both are comparable; otherwise preserve the rewritten comparison expression.