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

Use hash repartitioning for aggregates on dictionaries #3445

Merged
merged 1 commit into from
Sep 11, 2022

Conversation

isidentical
Copy link
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-actions github-actions bot added the core Core DataFusion crate label Sep 11, 2022
@codecov-commenter
Copy link

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 Files Coverage Δ
datafusion/core/src/physical_plan/planner.rs 77.37% <100.00%> (+0.21%) ⬆️
datafusion/expr/src/logical_plan/plan.rs 77.35% <0.00%> (ø)

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

@Dandandan Dandandan requested review from alamb and tustvold September 11, 2022 15:44
@isidentical isidentical marked this pull request as ready for review September 11, 2022 15:56
Copy link
Contributor

@Dandandan Dandandan left a comment

Choose a reason for hiding this comment

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

Looks good 💯

Copy link
Contributor

@alamb alamb left a comment

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:master Sep 11, 2022
@ursabot
Copy link

ursabot commented Sep 11, 2022

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 free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement vectorized hashing for dictionary types
5 participants