zabetak commented on code in PR #5795: URL: https://github.com/apache/hive/pull/5795#discussion_r2068653594
########## ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/SearchTransformer.java: ########## @@ -128,8 +132,23 @@ public Shuttle(final RexBuilder rexBuilder) { } else { return call; } + case IS_NULL: + case IS_NOT_NULL: + case CASE: + case COALESCE: + // Everything below must be transformed with the UNKNOWN handler Review Comment: There are some operators with special semantics that we need to retain the 3-valued logic even if we are inside the `WHERE` clause. Example: `COALESCE(SEARCH(...), true)` 1. If SEARCH -> true then COALESCE -> true 2. If SEARCH -> false then COALESCE -> false 3. If SEARCH -> null then COALESCE -> true If we consider `unknownAsFalse` inside the COALESCE then we will incorrectly drop the `IS NOT NULL` predicate during the expansion and the COALESCE will fall into the third case returning `true` instead of `false`. Basically, if the SEARCH is below/inside an operator that is sensitive to null values we cannot safely perform the simplification. Note that `RexSimplify` also changes the default unknown semantics for certain operators (see `simplifyIs2`, `simplifyCoalesce`, etc.). -- 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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org