suremarc commented on code in PR #7896:
URL: https://github.com/apache/arrow-datafusion/pull/7896#discussion_r1367839079
##########
datafusion/core/src/datasource/file_format/write/demux.rs:
##########
@@ -310,7 +311,37 @@ fn compute_partition_keys_by_row<'a>(
for i in 0..rb.num_rows() {
partition_values.push(array.value(i));
}
- }
+ },
+ DataType::Dictionary(key_type, _) => {
+ match **key_type{
+ DataType::UInt16 => {
Review Comment:
Hey Devin, there is a `downcast_dictionary_array!` macro that I encountered
while attempting to fix this issue. (I was going to submit a PR but was
figuring out if/how to add tests!) It lets you write code once that works for
all key types, if I am not mistaken. I saw it used elsewhere in DataFusion
code:
https://github.com/apache/arrow-datafusion/blob/9fde5c4282fd9f0e3332fb40998bf1562c17fcda/datafusion/common/src/hash_utils.rs#L326-L329
You can see the code I used here:
https://github.com/polygon-io/arrow-datafusion/blob/8c955891a6e5b6002faa07e54a67a6ec93347ade/datafusion/core/src/datasource/file_format/write/demux.rs#L316-L328
```rust
DataType::Dictionary(_, value_type)
if value_type.as_ref() == &DataType::Utf8 =>
{
downcast_dictionary_array!(
col_array => {
let array =
col_array.downcast_dict::<StringArray>().unwrap();
for i in 0..rb.num_rows() {
partition_values.push(array.value(i));
}
},
_ => unreachable!(),
)
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]