Skip to content

Use hash repartitioning for aggregates on dictionaries - #3445

Merged
alamb merged 1 commit into
apache:masterfrom
isidentical:gh-331
Sep 11, 2022
Merged

Use hash repartitioning for aggregates on dictionaries#3445
alamb merged 1 commit into
apache:masterfrom
isidentical:gh-331

Conversation

@isidentical

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes#331.

Rationale for this change

Hash repartitioning for aggregates on dictionaries was not available when it was initially implemented since dictionaries couldn't be hashed. The real issue in #331 (implementing vectorized hashing for dictionaries) is already resolved (by @alamb on #812), so as far as I can say we can safely remove this guard in the physical plan builder to leverage hash repartitioning on aggregates with dicts.

What changes are included in this PR?

Changes the physical plan builder to use hash repartitioning on dictionary-based aggregates.

Are there any user-facing changes?

This is an optimization, so there shouldn't be any behavioural change but the physical plans will change on some scenerios (like the example below).

Previous physical plan for the test hash_agg_group_by_partitioned_on_dicts:

AggregateExec: mode=Final, gby=[d1@0 as d1], aggr=[SUM(?table?.d2)]
CoalescePartitionsExec
AggregateExec: mode=Partial, gby=[d1@0 as d1], aggr=[SUM(?table?.d2)]
RepartitionExec: partitioning=RoundRobinBatch(4)
MemoryExec: partitions=1, partition_sizes=[1]

Current physical plan for it:

AggregateExec: mode=FinalPartitioned, gby=[d1@0 as d1], aggr=[SUM(?table?.d2)]
CoalesceBatchesExec: target_batch_size=4096
RepartitionExec: partitioning=Hash([Column { name: "d1", index: 0 }], 4)
AggregateExec: mode=Partial, gby=[d1@0 as d1], aggr=[SUM(?table?.d2)]
RepartitionExec: partitioning=RoundRobinBatch(4)
MemoryExec: partitions=1, partition_sizes=[1]

@github-actionsgithub-actionsBot added the core Core DataFusion crate label Sep 11, 2022
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #3445 (8d05c9f) into master (8df5496) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@ Coverage Diff @@## master #3445 +/- ##
=======================================
Coverage 85.69% 85.69% =======================================
Files 298 298 Lines 54644 54654 +10 =======================================
+ Hits 46826 46836 +10 
Misses 7818 7818 
Impacted FilesCoverage Δ
datafusion/core/src/physical_plan/planner.rs77.37% <100.00%> (+0.21%)⬆️
datafusion/expr/src/logical_plan/plan.rs77.35% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@isidentical
isidentical marked this pull request as ready for review September 11, 2022 15:56

@DandandanDandandan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 💯

@alambalamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @isidentical

@alamb
alamb merged commit 81addf7 into apache:masterSep 11, 2022
@ursabot

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = 8df5496 and contender = 81addf7. 81addf7 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coreCore DataFusion crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement vectorized hashing for dictionary types

5 participants

@isidentical@codecov-commenter@ursabot@Dandandan@alamb