Skip to content

Commit

Permalink
cleanup + fix typo
Browse files Browse the repository at this point in the history
Signed-off-by: Devan <[email protected]>
  • Loading branch information
devanbenz committed Aug 14, 2024
1 parent a0c78de commit 6b97d7b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions datafusion/functions/src/unicode/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ use std::any::Any;
use std::sync::Arc;

use arrow::array::{
ArrayAccessor, ArrayRef, AsArray, GenericStringArray, OffsetSizeTrait,
ArrayAccessor, ArrayIter, ArrayRef, AsArray, GenericStringArray, OffsetSizeTrait,
};
use arrow::datatypes::DataType;
use hashbrown::HashMap;
use unicode_segmentation::UnicodeSegmentation;

use crate::utils::{make_scalar_function, utf8_to_str_type};
use datafusion_common::cast::as_generic_string_array;
use datafusion_common::{exec_err, Result};
use datafusion_expr::TypeSignature::Exact;
use datafusion_expr::{ColumnarValue, ScalarUDFImpl, Signature, Volatility};
Expand Down Expand Up @@ -116,14 +115,13 @@ where
V: ArrayAccessor<Item = &'a str>,
B: ArrayAccessor<Item = &'a str>,
{
let string_array_iter = as_generic_string_array::<T>(&string_array)?;
let from_array_iter = as_generic_string_array::<T>(&from_array)?;
let to_array_iter = as_generic_string_array::<T>(&to_array)?;
let string_array_iter = ArrayIter::new(string_array);
let from_array_iter = ArrayIter::new(from_array);
let to_array_iter = ArrayIter::new(to_array);

let result = string_array_iter
.iter()
.zip(from_array_iter.iter())
.zip(to_array_iter.iter())
.zip(from_array_iter)
.zip(to_array_iter)
.map(|((string, from), to)| match (string, from, to) {
(Some(string), Some(from), Some(to)) => {
// create a hashmap of [char, index] to change from O(n) to O(1) for from list
Expand Down

0 comments on commit 6b97d7b

Please sign in to comment.