Skip to content

[POC] Introduce selection vector for hash aggregate - #4

Closed
goldmedal wants to merge 41 commits into
feat/selection-vector-partitionfrom
feat/hash-agg-sv
Closed

goldmedal wants to merge 41 commits into
feat/selection-vector-partitionfrom
feat/hash-agg-sv

Conversation

@goldmedal

@goldmedal goldmedal commented Apr 20, 2025 •

Copy link
Copy Markdown
Owner

Which issue does this PR close?

  • Closes #.

Rationale for this change

This PR only implements some of the hash aggregations:

  • The group by value is a primitive type.
  • count and the agg function, which uses GroupsAccumulator.

Benchmakr Result

  • Only run the query 4 and 7 of Clickbench.
--------------------
Benchmark clickbench_1.json
--------------------
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Query        ┃ feat_hash-agg-sv-disable ┃ feat_hash-agg-sv ┃    Change ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ QQuery 4     │                 311.74ms │         320.72ms │ no change │
│ QQuery 7     │                  30.28ms │          29.01ms │ no change │
└──────────────┴──────────────────────────┴──────────────────┴───────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Benchmark Summary                       ┃          ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ Total Time (feat_hash-agg-sv-disable)   │ 342.02ms │
│ Total Time (feat_hash-agg-sv)           │ 349.74ms │
│ Average Time (feat_hash-agg-sv-disable) │ 171.01ms │
│ Average Time (feat_hash-agg-sv)         │ 174.87ms │
│ Queries Faster                          │        0 │
│ Queries Slower                          │        0 │
│ Queries with No Change                  │        2 │
└─────────────────────────────────────────┴──────────┘

Comment on lines +118 to +125
if let Some(sv) = sv {
for idx in sv {
let v = if cols[0].as_primitive::<T>().is_null(*idx) {
None
} else {
Some(cols[0].as_primitive::<T>().value(*idx))
};
let group_id = match v {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

According to the selection indices, get the record by index iteratively.

@goldmedal goldmedal changed the title Introduce selection vector for hash aggregate [POC] Introduce selection vector for hash aggregate Apr 20, 2025
Comment on lines +829 to +836
let mut sv_mode = false;
let selection: Vec<usize> =
if let Some(array) = batch.column_by_name(SELECTION_FIELD_NAME) {
sv_mode = true;
array.as_boolean().values().set_indices().collect()
} else {
vec![]
};

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Where to get the selection vector.

@github-actions

Copy link
Copy Markdown

Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days.

@github-actions github-actions Bot added the Stale label Jul 10, 2025
@github-actions github-actions Bot closed this Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant