Skip to content
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

fix: incorrect set preserve_partitioning in SortExec #8485

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ fn try_swapping_with_sort(

Ok(Some(Arc::new(
SortExec::new(updated_exprs, make_with_child(projection, sort.input())?)
haohuaijin marked this conversation as resolved.
Show resolved Hide resolved
.with_fetch(sort.fetch()),
.with_fetch(sort.fetch())
.with_preserve_partitioning(sort.preserve_partitioning()),
)))
}

Expand Down
36 changes: 36 additions & 0 deletions datafusion/sqllogictest/test_files/join.slt
Original file line number Diff line number Diff line change
Expand Up @@ -594,3 +594,39 @@ drop table IF EXISTS full_join_test;
# batch size
statement ok
set datafusion.execution.batch_size = 8192;

# related to: https://github.com/apache/arrow-datafusion/issues/8374
statement ok
CREATE TABLE t1(a text, b int) AS VALUES ('Alice', 50), ('Alice', 100);

statement ok
CREATE TABLE t2(a text, b int) AS VALUES ('Alice', 2), ('Alice', 1);

# the current query results are incorrect, becuase the query was incorrectly rewritten as:
# SELECT t1.a, t1.b FROM t1 JOIN t2 ON t1.a = t2.a ORDER BY t1.a, t1.b;
# after https://github.com/apache/arrow-datafusion/issues/8374 fixed, the result should be:
# Alice 50
# Alice 100
# Alice 50
# Alice 100
waynexia marked this conversation as resolved.
Show resolved Hide resolved
query TI
SELECT t1.a, t1.b FROM t1 JOIN t2 ON t1.a = t2.a ORDER BY t1.a, t2.b;
----
Alice 50
Alice 50
Alice 100
Alice 100

query TITI
SELECT t1.a, t1.b, t2.a, t2.b FROM t1 JOIN t2 ON t1.a = t2.a ORDER BY t1.a, t2.b;
----
Alice 50 Alice 1
Alice 100 Alice 1
Alice 50 Alice 2
Alice 100 Alice 2

statement ok
DROP TABLE t1;

statement ok
DROP TABLE t2;