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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion datafusion-cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion datafusion/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ cranelift-module = { version = "0.82.0", optional = true }
ordered-float = "2.10"
parquet = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "a03d4eef5640e05dddf99fc2357ad6d58b5337cb", features = ["arrow"], optional = true }
pyo3 = { version = "0.16", optional = true }
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "34f22de680caa5fe586def5b336d56efe43c8cc4" }
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "e14d5bf45367edd8679cbc15ccee56693da8e4fb" }
2 changes: 1 addition & 1 deletion datafusion/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pin-project-lite= "^0.2.7"
pyo3 = { version = "0.16", optional = true }
rand = "0.8"
smallvec = { version = "1.6", features = ["union"] }
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "34f22de680caa5fe586def5b336d56efe43c8cc4" }
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "e14d5bf45367edd8679cbc15ccee56693da8e4fb" }
tempfile = "3"
tokio = { version = "1.0", features = ["macros", "rt", "rt-multi-thread", "sync", "fs", "parking_lot"] }
tokio-stream = "0.1"
Expand Down
17 changes: 17 additions & 0 deletions datafusion/core/src/execution/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2402,6 +2402,23 @@ mod tests {
];
assert_batches_eq!(expected, &result);

let result = ctx
.sql("SELECT 1 UNION DISTINCT SELECT 1")
.await
.unwrap()
.collect()
.await
.unwrap();

let expected = vec![
"+----------+",
"| Int64(1) |",
"+----------+",
"| 1 |",
"+----------+",
];
assert_batches_eq!(expected, &result);

Ok(())
}

Expand Down
35 changes: 21 additions & 14 deletions datafusion/core/src/sql/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ use sqlparser::ast::{
ArrayAgg, BinaryOperator, DataType as SQLDataType, DateTimeField, Expr as SQLExpr,
Fetch, FunctionArg, FunctionArgExpr, Ident, Join, JoinConstraint, JoinOperator,
ObjectName, Offset as SQLOffset, Query, Select, SelectItem, SetExpr, SetOperator,
ShowStatementFilter, TableFactor, TableWithJoins, TrimWhereField, UnaryOperator,
Value, Values as SQLValues, WithinGroup,
SetOperatorOption, ShowStatementFilter, TableFactor, TableWithJoins, TrimWhereField,
UnaryOperator, Value, Values as SQLValues, WithinGroup,
};
use sqlparser::ast::{ColumnDef as SQLColumnDef, ColumnOption};
use sqlparser::ast::{ObjectType, OrderByExpr, Statement};
Expand Down Expand Up @@ -365,27 +365,34 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
op,
left,
right,
all,
option,
} => {
let left_plan = self.set_expr_to_plan(*left, None)?;
let right_plan = self.set_expr_to_plan(*right, None)?;
match (op, all) {
(SetOperator::Union, true) => LogicalPlanBuilder::from(left_plan)
.union(right_plan)?
.build(),
(SetOperator::Union, false) => LogicalPlanBuilder::from(left_plan)
.union_distinct(right_plan)?
.build(),
(SetOperator::Intersect, true) => {
match (op, option) {
(SetOperator::Union, Some(SetOperatorOption::All)) => {
LogicalPlanBuilder::from(left_plan)
.union(right_plan)?
.build()
}
(SetOperator::Union, None)
| (SetOperator::Union, Some(SetOperatorOption::Distinct)) => {
LogicalPlanBuilder::from(left_plan)
.union_distinct(right_plan)?
.build()
}
(SetOperator::Intersect, Some(SetOperatorOption::All)) => {
LogicalPlanBuilder::intersect(left_plan, right_plan, true)
}
(SetOperator::Intersect, false) => {
(SetOperator::Intersect, None)
| (SetOperator::Intersect, Some(SetOperatorOption::Distinct)) => {
LogicalPlanBuilder::intersect(left_plan, right_plan, false)
}
(SetOperator::Except, true) => {
(SetOperator::Except, Some(SetOperatorOption::All)) => {
LogicalPlanBuilder::except(left_plan, right_plan, true)
}
(SetOperator::Except, false) => {
(SetOperator::Except, None)
| (SetOperator::Except, Some(SetOperatorOption::Distinct)) => {
LogicalPlanBuilder::except(left_plan, right_plan, false)
}
}
Expand Down
2 changes: 1 addition & 1 deletion datafusion/expr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ path = "src/lib.rs"
ahash = { version = "0.7", default-features = false }
arrow = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "a03d4eef5640e05dddf99fc2357ad6d58b5337cb", features = ["prettyprint"] }
datafusion-common = { path = "../common", version = "7.0.0" }
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "34f22de680caa5fe586def5b336d56efe43c8cc4" }
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "e14d5bf45367edd8679cbc15ccee56693da8e4fb" }
Loading