Skip to content

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Sep 25, 2024

Which issue does this PR close?

N/A

Rationale for this change

As part of reviewing the PR for #12269 from @jayzhan211 I found some
documentation that would make the code easier to understand.

What changes are included in this PR?

  1. Update documentation

Are these changes tested?

By docs CI

Are there any user-facing changes?

No functional changes, only docs

@alamb alamb added the documentation Improvements or additions to documentation label Sep 25, 2024
@alamb alamb marked this pull request as ready for review September 25, 2024 11:47
@github-actions github-actions bot added physical-expr Changes to the physical-expr crates and removed documentation Improvements or additions to documentation labels Sep 25, 2024
@alamb alamb requested a review from jayzhan211 September 25, 2024 18:01
use hashbrown::raw::RawTable;

/// Compare GroupValue Rows column by column
/// A [`GroupValues`] that stores multiple columns of group values.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not very familiar with it and thus the question, what is group values?
is it group keys, or exact values attached for specific key?

Copy link
Contributor

Choose a reason for hiding this comment

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

Consider the following example, (1, 'a') is one of the group values, so is (2, 'b') and (3, 'c')

statement ok
create table t(a int, b varchar) as values (1, 'a'), (2, 'b'), (1, 'a'), (3, 'c');

query ITI
select a, b, count(*) from t group by a, b;
----
1 a 2
2 b 1
3 c 1

Copy link
Contributor

@jayzhan211 jayzhan211 Sep 26, 2024

Choose a reason for hiding this comment

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

In Rows implementation, we convert (1, 'a') to row and compare against it. In Column implementation, we compare iteratively from 1 to 'a' in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a great example. I added in to the docs

/// An implementation of [`ArrayRowEq`] for primitive types.
pub struct PrimitiveGroupValueBuilder<T: ArrowPrimitiveType> {
group_values: Vec<T::Native>,
nulls: Vec<bool>,
Copy link
Contributor

Choose a reason for hiding this comment

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

should be it a BooleanArray? so this null checks will be faster and in 1 place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are foreshadowing :) This is an excellent point. @jayzhan211 and I are working on exactly this topic. #12623

Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

its good to me, leaving the final review to @jayzhan211
I would add an example or something on group keys/values, its not very obvious imho

fn take_n(&mut self, n: usize) -> ArrayRef;
}

/// An implementation of [`ArrayRowEq`] for primitive types.
Copy link
Contributor

Choose a reason for hiding this comment

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

was it renamed in #12619?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, good call -- will fix

}
}

/// An implementation of [`ArrayRowEq`] for binary and utf8 types.
Copy link
Contributor

Choose a reason for hiding this comment

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

renamed?

@alamb alamb added the documentation Improvements or additions to documentation label Sep 29, 2024
@alamb
Copy link
Contributor Author

alamb commented Sep 29, 2024

I would add an example or something on group keys/values, its not very obvious imho

Done!

Copy link
Contributor

@jayzhan211 jayzhan211 left a comment

Choose a reason for hiding this comment

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

👍

@jayzhan211
Copy link
Contributor

Thanks @alamb @comphead

@jayzhan211 jayzhan211 merged commit ba4488f into apache:main Sep 30, 2024
24 checks passed
@alamb alamb deleted the alamb/group_by_docs branch September 30, 2024 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation physical-expr Changes to the physical-expr crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants