Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions datafusion/sql/src/set_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
(SetOperator::Intersect, SetQuantifier::Distinct | SetQuantifier::None) => {
LogicalPlanBuilder::intersect(left_plan, right_plan, false)
}
(SetOperator::Except, SetQuantifier::All) => {
(SetOperator::Except | SetOperator::Minus, SetQuantifier::All) => {
LogicalPlanBuilder::except(left_plan, right_plan, true)
}
(SetOperator::Except, SetQuantifier::Distinct | SetQuantifier::None) => {
LogicalPlanBuilder::except(left_plan, right_plan, false)
}
(
SetOperator::Except | SetOperator::Minus,
SetQuantifier::Distinct | SetQuantifier::None,
) => LogicalPlanBuilder::except(left_plan, right_plan, false),
(op, quantifier) => {
not_impl_err!("{op} {quantifier} not implemented")
}
Expand Down
19 changes: 19 additions & 0 deletions datafusion/sql/tests/sql_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3436,6 +3436,25 @@ fn except_with_duplicate_expressions() {
);
}

#[test]
fn minus_is_an_alias_for_except() {
let sql = "SELECT order_id FROM orders MINUS SELECT order_id FROM orders";
let plan = logical_plan_with_dialect(sql, &SnowflakeDialect {}).unwrap();
assert_snapshot!(
plan,
@r"
LeftAnti Join: left.order_id = right.order_id
Distinct:
SubqueryAlias: left
Projection: orders.order_id
TableScan: orders
SubqueryAlias: right
Projection: orders.order_id
TableScan: orders
"
);
}

#[test]
fn empty_over() {
let sql = "SELECT order_id, MAX(order_id) OVER () from orders";
Expand Down
Loading