File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
datafusion/functions/src/unicode Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -170,7 +170,8 @@ where
170170 // Build from_map using reusable buffer
171171 from_graphemes. extend ( from. graphemes ( true ) ) ;
172172 for ( index, c) in from_graphemes. iter ( ) . enumerate ( ) {
173- from_map. insert ( * c, index) ;
173+ // Ignore characters that already exist in from_map, else insert
174+ from_map. entry ( * c) . or_insert ( index) ;
174175 }
175176
176177 // Build to_graphemes
@@ -259,6 +260,18 @@ mod tests {
259260 Utf8 ,
260261 StringArray
261262 ) ;
263+ test_function ! (
264+ TranslateFunc :: new( ) ,
265+ vec![
266+ ColumnarValue :: Scalar ( ScalarValue :: from( "abcabc" ) ) ,
267+ ColumnarValue :: Scalar ( ScalarValue :: from( "aa" ) ) ,
268+ ColumnarValue :: Scalar ( ScalarValue :: from( "de" ) )
269+ ] ,
270+ Ok ( Some ( "dbcdbc" ) ) ,
271+ & str ,
272+ Utf8 ,
273+ StringArray
274+ ) ;
262275 test_function ! (
263276 TranslateFunc :: new( ) ,
264277 vec![
You can’t perform that action at this time.
0 commit comments