julianhyde commented on pull request #2357:
URL: https://github.com/apache/calcite/pull/2357#issuecomment-786175844


   @aigor 
   
   > I run your pull-request through our test suites (in a downstream project).
   > I was not able to detect any serious issues.
   
   Thank you! This helps a lot.
   
   > RexUtil.expandSearch() misses the opportunity to simplify some filters.
   
   Previously it was incorrect. The expression `SEARCH($1, Sarg[[1000..2000]; 
NULL AS FALSE])` must return FALSE if $1 is null, but the previous expansion 
`AND(>=($1, 1000), <=($1, 2000))` would instead return UNKNOWN.
   
   There's some subtle interaction between Sarg's 'nullAs' field and the 
'unknownAs' behavior during code generation. If you're implementing `WHERE x 
BETWEEN 1000 AND 2000`, you want an expression that returns either UNKNOWN or 
FALSE if x is null. You don't actually care which, and if you're generating SQL 
you probably prefer `x >= 1000 AND x <= 2000` to `x IS NOT NULL AND x >= 1000 
AND x <= 2000` because it's shorter.
   
   So, your use case is a bug somewhere in the query preparation process, but I 
think `expandSearch` is now doing the right thing.


----------------------------------------------------------------
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.

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


Reply via email to