Skip to content

Commit 016c22f

Browse files
committed
Signed-off-by: Alex Qyoun-ae <[email protected]>
1 parent 7803f7e commit 016c22f

File tree

7 files changed

+43
-19
lines changed

7 files changed

+43
-19
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion-cli/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion/common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ cranelift-module = { version = "0.82.0", optional = true }
4444
ordered-float = "2.10"
4545
parquet = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "a03d4eef5640e05dddf99fc2357ad6d58b5337cb", features = ["arrow"], optional = true }
4646
pyo3 = { version = "0.16", optional = true }
47-
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "34f22de680caa5fe586def5b336d56efe43c8cc4" }
47+
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "e14d5bf45367edd8679cbc15ccee56693da8e4fb" }

datafusion/core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pin-project-lite= "^0.2.7"
7979
pyo3 = { version = "0.16", optional = true }
8080
rand = "0.8"
8181
smallvec = { version = "1.6", features = ["union"] }
82-
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "34f22de680caa5fe586def5b336d56efe43c8cc4" }
82+
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "e14d5bf45367edd8679cbc15ccee56693da8e4fb" }
8383
tempfile = "3"
8484
tokio = { version = "1.0", features = ["macros", "rt", "rt-multi-thread", "sync", "fs", "parking_lot"] }
8585
tokio-stream = "0.1"

datafusion/core/src/execution/context.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,6 +2402,23 @@ mod tests {
24022402
];
24032403
assert_batches_eq!(expected, &result);
24042404

2405+
let result = ctx
2406+
.sql("SELECT 1 UNION DISTINCT SELECT 1")
2407+
.await
2408+
.unwrap()
2409+
.collect()
2410+
.await
2411+
.unwrap();
2412+
2413+
let expected = vec![
2414+
"+----------+",
2415+
"| Int64(1) |",
2416+
"+----------+",
2417+
"| 1 |",
2418+
"+----------+",
2419+
];
2420+
assert_batches_eq!(expected, &result);
2421+
24052422
Ok(())
24062423
}
24072424

datafusion/core/src/sql/planner.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ use sqlparser::ast::{
5757
ArrayAgg, BinaryOperator, DataType as SQLDataType, DateTimeField, Expr as SQLExpr,
5858
Fetch, FunctionArg, FunctionArgExpr, Ident, Join, JoinConstraint, JoinOperator,
5959
ObjectName, Offset as SQLOffset, Query, Select, SelectItem, SetExpr, SetOperator,
60-
ShowStatementFilter, TableFactor, TableWithJoins, TrimWhereField, UnaryOperator,
61-
Value, Values as SQLValues, WithinGroup,
60+
SetOperatorOption, ShowStatementFilter, TableFactor, TableWithJoins, TrimWhereField,
61+
UnaryOperator, Value, Values as SQLValues, WithinGroup,
6262
};
6363
use sqlparser::ast::{ColumnDef as SQLColumnDef, ColumnOption};
6464
use sqlparser::ast::{ObjectType, OrderByExpr, Statement};
@@ -365,27 +365,34 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
365365
op,
366366
left,
367367
right,
368-
all,
368+
option,
369369
} => {
370370
let left_plan = self.set_expr_to_plan(*left, None)?;
371371
let right_plan = self.set_expr_to_plan(*right, None)?;
372-
match (op, all) {
373-
(SetOperator::Union, true) => LogicalPlanBuilder::from(left_plan)
374-
.union(right_plan)?
375-
.build(),
376-
(SetOperator::Union, false) => LogicalPlanBuilder::from(left_plan)
377-
.union_distinct(right_plan)?
378-
.build(),
379-
(SetOperator::Intersect, true) => {
372+
match (op, option) {
373+
(SetOperator::Union, Some(SetOperatorOption::All)) => {
374+
LogicalPlanBuilder::from(left_plan)
375+
.union(right_plan)?
376+
.build()
377+
}
378+
(SetOperator::Union, None)
379+
| (SetOperator::Union, Some(SetOperatorOption::Distinct)) => {
380+
LogicalPlanBuilder::from(left_plan)
381+
.union_distinct(right_plan)?
382+
.build()
383+
}
384+
(SetOperator::Intersect, Some(SetOperatorOption::All)) => {
380385
LogicalPlanBuilder::intersect(left_plan, right_plan, true)
381386
}
382-
(SetOperator::Intersect, false) => {
387+
(SetOperator::Intersect, None)
388+
| (SetOperator::Intersect, Some(SetOperatorOption::Distinct)) => {
383389
LogicalPlanBuilder::intersect(left_plan, right_plan, false)
384390
}
385-
(SetOperator::Except, true) => {
391+
(SetOperator::Except, Some(SetOperatorOption::All)) => {
386392
LogicalPlanBuilder::except(left_plan, right_plan, true)
387393
}
388-
(SetOperator::Except, false) => {
394+
(SetOperator::Except, None)
395+
| (SetOperator::Except, Some(SetOperatorOption::Distinct)) => {
389396
LogicalPlanBuilder::except(left_plan, right_plan, false)
390397
}
391398
}

datafusion/expr/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ path = "src/lib.rs"
3838
ahash = { version = "0.7", default-features = false }
3939
arrow = { git = 'https://github.com/cube-js/arrow-rs.git', rev = "a03d4eef5640e05dddf99fc2357ad6d58b5337cb", features = ["prettyprint"] }
4040
datafusion-common = { path = "../common", version = "7.0.0" }
41-
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "34f22de680caa5fe586def5b336d56efe43c8cc4" }
41+
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "e14d5bf45367edd8679cbc15ccee56693da8e4fb" }

0 commit comments

Comments
 (0)