yangzhg opened a new issue #2834: [Proposal] Full support of set operations: 
add INTERSECT and EXCEPT set operators
URL: https://github.com/apache/incubator-doris/issues/2834
 
 
   # Description
   Generaly set functionality includes the below. but now doris has just 
support UNION & UNION ALL.
   ```
   UNION [DISTINCT | ALL]
   
   INTERSECT [DISTINCT | ALL]
   
   EXCEPT [DISTINCT | ALL]
   ```
   `EXCEPT ` in some systems is an alias for `MINUS`
   
   `INTERSECT` operator is used to return the results of 2 or more `SELECT` 
statements. However, it only returns the rows selected by all queries or data 
sets. If a record exists in one query and not in the other, it will be omitted 
from the `INTERSECT` results.
   
![image](https://user-images.githubusercontent.com/9098473/73837289-1a0d1200-484c-11ea-9057-20aeb375a8d7.png)
   The `EXCEPT` operator is used to return all rows in the first `SELECT` 
statement that are not returned by the second `SELECT` statement. Each `SELECT` 
statement will define a dataset. The `EXCEPT` operator will retrieve all 
records from the first dataset and then remove from the results all records 
from the second dataset.
   
![image](https://user-images.githubusercontent.com/9098473/73837373-4a54b080-484c-11ea-8ddf-2f7b6009c03d.png)
   
   # Syntax
   ## INTERSECT
   ```
   SELECT expression1, expression2, ... expression_n
   FROM tables
   [WHERE conditions]
   INTERSECT [DISTINCT | ALL]
   SELECT expression1, expression2, ... expression_n
   FROM tables
   [WHERE conditions];
   ```
   ## EXCEPT
   ```
   SELECT expression1, expression2, ... expression_n
   FROM tables
   [WHERE conditions]
   EXCEPT|MINUS [DISTINCT | ALL]
   SELECT expression1, expression2, ... expression_n
   FROM tables
   [WHERE conditions];
   ```
   # Subtasks
   * Convert UnionStmt class into to SetOperationStmt, add Syntax support to 
sqlparser.cup
   * Add INTERSECT and EXCEPT support to SetOperationStmt and planner
   * Implements IntersectNode and ExceptNode
   
   
   
   
   
   
   
   
   
   

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to