Skip to content

Commit eb41915

Browse files
committed
fix clippy errors & inline final builder
1 parent 52f620a commit eb41915

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

‎datafusion/physical-plan/src/aggregates/group_values/multi_group_by/dictionary.rs‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct DictionaryGroupValuesColumn<K: ArrowDictionaryKeyType + Send + Sync>
3232
}
3333

3434
impl<K: ArrowDictionaryKeyType + Send + Sync> DictionaryGroupValuesColumn<K> {
35-
pub fn new(inner: Box<dyn GroupColumn>, field: Field) -> Self {
35+
pub fn new(inner: Box<dyn GroupColumn>, field: &Field) -> Self {
3636
let null_array = arrow::array::new_null_array(field.data_type(), 1);
3737
Self {
3838
inner,
@@ -41,7 +41,10 @@ impl<K: ArrowDictionaryKeyType + Send + Sync> DictionaryGroupValuesColumn<K> {
4141
}
4242
}
4343

44+
#[inline]
4445
fn into_dict(values: ArrayRef) -> ArrayRef {
46+
// at some point in the future we may want to support bumping the key types
47+
// https://github.com/apache/datafusion/issues/23127
4548
let keys: PrimitiveArray<K> = (0..values.len())
4649
.map(|i| {
4750
if values.is_null(i) {
@@ -83,18 +86,18 @@ impl<K: ArrowDictionaryKeyType + Send + Sync> GroupColumn
8386
) {
8487
let dict = array.as_dictionary::<K>();
8588
let keys = dict.keys();
89+
let values = dict.values();
8690

8791
if keys.null_count() == 0 {
8892
let key_indices: Vec<usize> =
8993
rhs_rows.iter().map(|&r| keys.value(r).as_usize()).collect();
9094
self.inner.vectorized_equal_to(
9195
lhs_rows,
92-
dict.values(),
96+
values,
9397
&key_indices,
9498
equal_to_results,
9599
);
96100
} else {
97-
let values = dict.values();
98101
for (i, (lhs_row, rhs_row)) in lhs_rows.iter().zip(rhs_rows).enumerate() {
99102
if equal_to_results.get_bit(i) {
100103
let result = match dict.key(*rhs_row) {
@@ -160,7 +163,7 @@ mod tests {
160163
let field = Field::new("", DataType::Utf8, true);
161164
DictionaryGroupValuesColumn::<Int32Type>::new(
162165
Box::new(ByteGroupValueBuilder::<i32>::new(OutputType::Utf8)),
163-
field,
166+
&field,
164167
)
165168
}
166169

‎datafusion/physical-plan/src/aggregates/group_values/multi_group_by/mod.rs‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,28 +1073,28 @@ fn make_group_column(field: &Field) -> Result<Box<dyn GroupColumn>> {
10731073
let col: Box<dyn GroupColumn> = match key_dt.as_ref() {
10741074
DataType::Int8 => Box::new(dictionary::DictionaryGroupValuesColumn::<
10751075
Int8Type,
1076-
>::new(inner, new_field)),
1076+
>::new(inner, &new_field)),
10771077
DataType::Int16 => Box::new(dictionary::DictionaryGroupValuesColumn::<
10781078
Int16Type,
1079-
>::new(inner, new_field)),
1079+
>::new(inner, &new_field)),
10801080
DataType::Int32 => Box::new(dictionary::DictionaryGroupValuesColumn::<
10811081
Int32Type,
1082-
>::new(inner, new_field)),
1082+
>::new(inner, &new_field)),
10831083
DataType::Int64 => Box::new(dictionary::DictionaryGroupValuesColumn::<
10841084
Int64Type,
1085-
>::new(inner, new_field)),
1085+
>::new(inner, &new_field)),
10861086
DataType::UInt8 => Box::new(dictionary::DictionaryGroupValuesColumn::<
10871087
UInt8Type,
1088-
>::new(inner, new_field)),
1088+
>::new(inner, &new_field)),
10891089
DataType::UInt16 => Box::new(dictionary::DictionaryGroupValuesColumn::<
10901090
UInt16Type,
1091-
>::new(inner, new_field)),
1091+
>::new(inner, &new_field)),
10921092
DataType::UInt32 => Box::new(dictionary::DictionaryGroupValuesColumn::<
10931093
UInt32Type,
1094-
>::new(inner, new_field)),
1094+
>::new(inner, &new_field)),
10951095
DataType::UInt64 => Box::new(dictionary::DictionaryGroupValuesColumn::<
10961096
UInt64Type,
1097-
>::new(inner, new_field)),
1097+
>::new(inner, &new_field)),
10981098
_ => {
10991099
return not_impl_err!(
11001100
"Dictionary key type {key_dt} not supported in GroupValuesColumn"

0 commit comments

Comments
 (0)