mustafasrepo commented on code in PR #11875:
URL: https://github.com/apache/datafusion/pull/11875#discussion_r1707228670
##########
datafusion/core/src/dataframe/mod.rs:
##########
@@ -3019,11 +3019,11 @@ mod tests {
assert_batches_sorted_eq!(
[
- "+-----+-----+----+-------+",
Review Comment:
Result of this test changes with this PR. I have analyzed the change,
previously this tes was generating the following plan:
```
"ProjectionExec: expr=[c1@0 as c1, c2@1 as c2, c3@2 as c3, CAST(c2@1 AS
Int8) + c3@2 as sum]",
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1",
" SortExec: expr=[c1@0 ASC,c2@1 ASC,c3@2 ASC],
preserve_partitioning=[false]",
" GlobalLimitExec: skip=0, fetch=1",
" CoalescePartitionsExec",
" CoalesceBatchesExec: target_batch_size=8192, fetch=1",
" FilterExec: c2@1 = 3 AND c1@0 = a",
" RepartitionExec: partitioning=RoundRobinBatch(8),
input_partitions=1",
" CsvExec: file_groups={1 group:
[[Users/akurmustafa/projects/synnada/datafusion-upstream/testing/data/csv/aggregate_test_100.csv]]},
projection=[c1, c2, c3], has_header=true",
```
After the changes in this PR, following plan is generated
```
"ProjectionExec: expr=[c1@0 as c1, c2@1 as c2, c3@2 as c3, CAST(c2@1 AS
Int8) + c3@2 as sum]",
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1",
" SortExec: TopK(fetch=1), expr=[c3@2 ASC],
preserve_partitioning=[false]",
" CoalescePartitionsExec",
" CoalesceBatchesExec: target_batch_size=8192",
" FilterExec: c2@1 = 3 AND c1@0 = a",
" RepartitionExec: partitioning=RoundRobinBatch(8),
input_partitions=1",
" CsvExec: file_groups={1 group:
[[Users/akurmustafa/projects/synnada/datafusion-upstream/testing/data/csv/aggregate_test_100.csv]]},
projection=[c1, c2, c3], has_header=true",
```
I think the plan is effectively same. However, the result of the test is not
deterministic as is.
With this observation, I have updated the place of the limit to make sure
result of the plan is deterministic after execution. With the change of the
place of the limit, the following plan is generated:
```
"ProjectionExec: expr=[c1@0 as c1, c2@1 as c2, c3@2 as c3, CAST(c2@1 AS
Int8) + c3@2 as sum]",
" RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1",
" GlobalLimitExec: skip=0, fetch=1",
" SortPreservingMergeExec: [c1@0 ASC,c2@1 ASC,c3@2 ASC], fetch=1",
" SortExec: TopK(fetch=1), expr=[c3@2 ASC],
preserve_partitioning=[true]",
" CoalesceBatchesExec: target_batch_size=8192",
" FilterExec: c2@1 = 3 AND c1@0 = a",
" RepartitionExec: partitioning=RoundRobinBatch(8),
input_partitions=1",
" CsvExec: file_groups={1 group:
[[Users/akurmustafa/projects/synnada/datafusion-upstream/testing/data/csv/aggregate_test_100.csv]]},
projection=[c1, c2, c3], has_header=true",
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]