-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement EXCEPT & EXCEPT DISTINCT #1259
Conversation
PTAL, thanks❤️ @alamb @houqp @Dandandan |
datafusion/src/sql/planner.rs
Outdated
@@ -195,26 +195,42 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { | |||
} => { | |||
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 join_keys = left_plan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am a bit concerned about the extra overhead here for the union branches. perhaps also relevant to https://github.com/apache/arrow-datafusion/pull/1258/files#r744178212
392a134
to
7cedf95
Compare
I extracted some duplicate code, you can review this ticket firstly. After the ticket is merged, I'll update #1258 and #1261 @houqp @alamb @Dandandan |
datafusion/tests/sql.rs
Outdated
let sql = "SELECT * FROM (SELECT null AS id1, 1 AS id2) t1 | ||
EXCEPT SELECT * FROM (SELECT null AS id1, 2 AS id2) t2"; | ||
|
||
let expected: Vec<Vec<String>> = vec![vec!["NULL".to_string(), "1".to_string()]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using &str
is possible here too I think, maybe easier to remove the explicit type.
7cedf95
to
f192309
Compare
datafusion/src/sql/planner.rs
Outdated
LogicalPlanBuilder::intersect_or_except( | ||
left_plan, | ||
right_plan, | ||
JoinType::Semi, | ||
false, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it would be cleaner to turn this and except into a simple public wrapper method in logical plan builder so users won't need to worry about which join type to pass in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice suggestion!
f192309
to
550473d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks great -- nice work @xudong963
} | ||
|
||
/// Process intersect or except | ||
fn intersect_or_except( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is nice
"Only UNION ALL and UNION [DISTINCT] and INTERSECT and INTERSECT [DISTINCT] are supported, found {}", | ||
op | ||
))), | ||
(SetOperator::Union, true) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that certainly looks nicer
Which issue does this PR close?
Closes #1082
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?