Skip to content

Commit

Permalink
Rename string_concat to concat_elements_utf8 (#1754)
Browse files Browse the repository at this point in the history
* Rename `string_concat` to `concat_elements_string`

* Rename `string_concat` to `concat_elements_utf8`
  • Loading branch information
alamb authored May 26, 2022
1 parent 7e8fbf9 commit b265780
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions arrow/src/compute/kernels/concat_elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ use crate::array::*;
use crate::compute::util::combine_option_bitmap;
use crate::error::{ArrowError, Result};

/// Returns the elementwise concatenation of `StringArray`.
/// Returns the elementwise concatenation of a [`StringArray`].
///
/// An index of the resulting `StringArray` is null if any of `StringArray` are null at that location.
/// An index of the resulting [`StringArray`] is null if any of
/// `StringArray` are null at that location.
///
/// ```text
/// e.g:
Expand All @@ -31,8 +32,8 @@ use crate::error::{ArrowError, Result};
/// ["a", "b"] + [None, "c"] = [None, "bc"]
/// ```
///
/// Attention: `left` and `right` must have the same length.
pub fn string_concat<Offset: OffsetSizeTrait>(
/// An error will be returned if `left` and `right` have different lengths
pub fn concat_elements_utf8<Offset: OffsetSizeTrait>(
left: &GenericStringArray<Offset>,
right: &GenericStringArray<Offset>,
) -> Result<GenericStringArray<Offset>> {
Expand Down Expand Up @@ -100,7 +101,7 @@ mod tests {
.into_iter()
.collect::<StringArray>();

let output = string_concat(&left, &right).unwrap();
let output = concat_elements_utf8(&left, &right).unwrap();

let expected = [None, Some("baryyy"), None]
.into_iter()
Expand All @@ -118,7 +119,7 @@ mod tests {
.into_iter()
.collect::<StringArray>();

let output = string_concat(&left, &right).unwrap();
let output = concat_elements_utf8(&left, &right).unwrap();

let expected = [Some("foobaz"), Some(""), Some("bar")]
.into_iter()
Expand All @@ -132,7 +133,7 @@ mod tests {
let left = StringArray::from(vec!["foo", "bar"]);
let right = StringArray::from(vec!["bar", "baz"]);

let output = string_concat(&left, &right).unwrap();
let output = concat_elements_utf8(&left, &right).unwrap();

let expected = StringArray::from(vec!["foobar", "barbaz"]);

Expand All @@ -144,7 +145,7 @@ mod tests {
let left = StringArray::from(vec!["foo", "bar"]);
let right = StringArray::from(vec!["baz"]);

let output = string_concat(&left, &right);
let output = concat_elements_utf8(&left, &right);

assert!(output.is_err());
}
Expand All @@ -156,7 +157,7 @@ mod tests {

let left_slice = left.slice(0, 3);
let right_slice = right.slice(1, 3);
let output = string_concat(
let output = concat_elements_utf8(
left_slice
.as_any()
.downcast_ref::<GenericStringArray<i32>>()
Expand All @@ -177,7 +178,7 @@ mod tests {
let left_slice = left.slice(2, 2);
let right_slice = right.slice(1, 2);

let output = string_concat(
let output = concat_elements_utf8(
left_slice
.as_any()
.downcast_ref::<GenericStringArray<i32>>()
Expand Down

0 comments on commit b265780

Please sign in to comment.