vlsi commented on PR #3247:
URL: https://github.com/apache/calcite/pull/3247#issuecomment-6120582285

   CALCITE-5733 is already fixed on `main` by 92cfb30, released in 1.42.0: 
`RexProgramTest.testSimplifyArrayEquality` covers `a = ARRAY[1,2] AND a = 
ARRAY[2,3]`.
   
   One case from CALCITE-5733 is still not simplified on `main`: the 
FLINK-32188 shape, where each array constructor is cast to the column type. I 
filed it as [CALCITE-7850](https://issues.apache.org/jira/browse/CALCITE-7850); 
a fix for it belongs in a new PR against `main`.
   
   This branch cannot be the base for that PR, because it simplifies 
satisfiable conditions to `FALSE` and throws on others. The first four inputs 
are in a filter (`unknownAs = FALSE`):
   
   - `$1 = 1 AND $0 = ARRAY[1, 2]` becomes `FALSE`: `recordedArray` is set only 
when the array comparison is the first term, so a later one is compared with 
`null`, or with an array left by an earlier call.
   - `$0 = ARRAY[1, 2] AND $2 = ARRAY[2, 3]` becomes `FALSE`: the two 
comparisons are on different columns, and `Comparison.ref` is never compared.
   - `$0 <> ARRAY[1] AND $0 <> ARRAY[2]` becomes `FALSE`: `Comparison.kind` is 
never checked.
   - `$0 = ARRAY[$1] AND $0 = ARRAY[$3]` becomes `FALSE`, although `$1` may 
equal `$3`: the constructor operands are compared as expressions, and nothing 
checks that they are constants.
   - `$0 = ARRAY[1, 2] AND $0 = ARRAY[1, 2]` in a filter throws 
`NullPointerException` in `simplifyAnd2ForUnknownAsFalse`, and `OR($0 <> 
ARRAY[1], $0 <> ARRAY[2])` throws it in `simplifyUsingPredicates` in either 
mode. The new `Comparison` constructor sets `literal` to `null`, and both 
methods call `comparison.literal.getValue()` unconditionally.
   - `recordedArray` is the only mutable field of `RexSimplify`, and 
`RelBuilder` reuses one instance across `filter()` calls, so the result of one 
`simplify` call depends on the previous one.
   
   I'm closing this PR as superseded by 92cfb30.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to