yujun777 commented on PR #69921:
URL: https://github.com/apache/doris/pull/69921#issuecomment-6573881958

   Could we update the duplicate-candidate handling together with the relaxed 
independence check?
   
   `getCandidates()` still calls `candidates.clear()` and breaks when it sees 
another candidate for the same expression. The relaxation makes this reachable 
for shared-slot candidates and can discard useful candidates for unrelated 
slots as well.
   
   For example, consider the expression passed to `rewriteTree(Expression)`:
   
   ```sql
   (
       b = 10
       AND a = 1
       AND ((a = 1 AND c = 100) OR (a = 2 AND c = 200))
   )
   OR (b = 20 AND a = 3)
   ```
   
   The bottom-up rewrite of the inner OR adds `a IN (1, 2)` alongside the 
retained inner OR. In the first outer disjunct, candidate collection then sees 
`b = 10`, `a = 1`, and `a IN (1, 2)`. Both `a` candidates now pass the relaxed 
check, but the second one clears the entire map, including `b`. With the 
previous independence check, the shared `a` candidates were skipped and `b IN 
(10, 20)` could still be inferred at the outer level.
   
   Within a conjunction, compatible constraints on the same slot should be 
combined by intersection: `a = 1 AND a IN (1, 2)` gives `a = 1`. Across 
disjuncts, their candidate values are combined by union. Please preserve the 
existing type/NULL semantics, especially when an intersection is empty, and 
avoid discarding candidates for other slots. A test through 
`rewriteTree(Expression)`, the entry point used by `InferInPredicateFromOr`, 
would cover this nested shape. This is a rule-level inference regression; I 
have not established an end-to-end query slowdown or a wrong-result case.
   
   **Non-blocking suggestion:** I would prefer removing 
`enable_or_to_in_shared_slot_inference`. This rewrite does not introduce a 
user-selectable semantic behavior, and adding a permanent FE config solely as a 
safeguard against possible implementation bugs adds configuration and 
maintenance complexity. The rule's guards and tests should establish 
correctness. Removing the config is a suggestion, not a requirement for 
merging; the duplicate-candidate handling above is a separate concern.
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to