Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions datafusion/common/src/scalar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,8 +881,21 @@ fn dict_from_scalar<K: ArrowDictionaryKeyType>(
))
}

/// Create a dictionary array representing all the values in values
fn dict_from_values<K: ArrowDictionaryKeyType>(
/// Create a `DictionaryArray` from the provided values array.
///
/// Each element gets a unique key (`0..N-1`), without deduplication.
/// Useful for wrapping arrays in dictionary form.
///
/// # Input
/// ["alice", "bob", "alice", null, "carol"]
///
/// # Output
/// `DictionaryArray<Int32>`
/// {
/// keys: [0, 1, 2, 3, 4],
/// values: ["alice", "bob", "alice", null, "carol"]
/// }
pub fn dict_from_values<K: ArrowDictionaryKeyType>(
values_array: ArrayRef,
) -> Result<ArrayRef> {
// Create a key array with `size` elements of 0..array_len for all
Expand Down