alamb commented on a change in pull request #1068:
URL: https://github.com/apache/arrow-datafusion/pull/1068#discussion_r721261127



##########
File path: datafusion/tests/user_defined_plan.rs
##########
@@ -128,6 +128,8 @@ const QUERY1: &str = "SELECT * FROM sales limit 3";
 const QUERY: &str =
     "SELECT customer_id, revenue FROM sales ORDER BY revenue DESC limit 3";
 
+const QUERY2: &str = "SELECT customer_id, revenue FROM sales  UNION SELECT 
customer_id, revenue FROM sales ORDER BY revenue DESC limit 3";

Review comment:
       Can you please move this test into `tests/sql.rs`? I don't think `UNION` 
has anything to do with user defined plans.

##########
File path: datafusion/src/sql/planner.rs
##########
@@ -170,8 +170,16 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
                     let right_plan = self.set_expr_to_plan(right.as_ref(), 
None, ctes)?;
                     union_with_alias(left_plan, right_plan, alias)
                 }
+                (SetOperator::Union, false) => {
+                    let left_plan = self.set_expr_to_plan(left.as_ref(), None, 
ctes)?;
+                    let right_plan = self.set_expr_to_plan(right.as_ref(), 
None, ctes)?;
+                    let union_plan = union_with_alias(left_plan, right_plan, 
alias)?;
+                    LogicalPlanBuilder::from(union_plan)

Review comment:
       ❤️ 

##########
File path: datafusion/src/logical_plan/builder.rs
##########
@@ -291,6 +291,15 @@ impl LogicalPlanBuilder {
         Ok(Self::from(union_with_alias(self.plan.clone(), plan, None)?))
     }
 
+    /// apply union distinct
+    pub fn union_distinct(&self) -> Result<Self> {

Review comment:
       ```suggestion
       /// Apply deduplication: Only distinct (different) values are returned)
       pub fn distinct(&self) -> Result<Self> {
   ```
   
   I suggest renaming this to just `distinct` as there is only one input, so I 
find the use of the term `union` somewhat confusing




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