Skip to content

Commit d83a290

Browse files
minor: make dict_from_values public (#17376)
* minor: make dict_from_values public * Update datafusion/common/src/scalar/mod.rs Co-authored-by: Oleks V <[email protected]> * fix format * one more format --------- Co-authored-by: Oleks V <[email protected]>
1 parent e6c4f0d commit d83a290

File tree

1 file changed

+15
-2
lines changed
  • datafusion/common/src/scalar

1 file changed

+15
-2
lines changed

datafusion/common/src/scalar/mod.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,21 @@ fn dict_from_scalar<K: ArrowDictionaryKeyType>(
881881
))
882882
}
883883

884-
/// Create a dictionary array representing all the values in values
885-
fn dict_from_values<K: ArrowDictionaryKeyType>(
884+
/// Create a `DictionaryArray` from the provided values array.
885+
///
886+
/// Each element gets a unique key (`0..N-1`), without deduplication.
887+
/// Useful for wrapping arrays in dictionary form.
888+
///
889+
/// # Input
890+
/// ["alice", "bob", "alice", null, "carol"]
891+
///
892+
/// # Output
893+
/// `DictionaryArray<Int32>`
894+
/// {
895+
/// keys: [0, 1, 2, 3, 4],
896+
/// values: ["alice", "bob", "alice", null, "carol"]
897+
/// }
898+
pub fn dict_from_values<K: ArrowDictionaryKeyType>(
886899
values_array: ArrayRef,
887900
) -> Result<ArrayRef> {
888901
// Create a key array with `size` elements of 0..array_len for all

0 commit comments

Comments
 (0)