alpass163 opened a new pull request, #16700:
URL: https://github.com/apache/iotdb/pull/16700

   Description:
   
   This PR introduces logical planning support for INTERSECT DISTINCT and 
INTERSECT ALL set operations by adding two new iterative rewrite rules.
   
   ImplementIntersectDistinctAsUnion: This rule rewrites INTERSECT DISTINCT. It 
translates the operation into a plan that aggregates row counts from all 
sources and then applies a FilterNode. The filter predicate ensures that only 
rows present in all relations (i.e., countA >= 1 AND countB >= 1...) are kept.
   
   ImplementIntersectAll: This rule implements INTERSECT ALL. It uses a similar 
translation but applies a different filter: row_number <= LEAST(countA, countB, 
...). This correctly limits the output to the minimum number of duplicate 
occurrences found across all inputs, adhering to ALL semantics.
   
   Additionally, the parser grammar for queryTerm correctly defines INTERSECT 
before UNION and EXCEPT. This ensures INTERSECT has higher operator precedence, 
correctly parsing expressions like A UNION B INTERSECT C as A UNION (B 
INTERSECT C).


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