Skip to content

Commit

Permalink
rebase/update for PlSmallStr
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie committed Nov 3, 2024
1 parent 4836ee3 commit 339fc9c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions crates/polars-plan/src/dsl/name.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#[cfg(feature = "regex")]
use regex::Regex;
use polars_utils::format_pl_smallstr;
#[cfg(feature = "dtype-struct")]
use polars_utils::pl_str::PlSmallStr;
#[cfg(feature = "regex")]
use regex::Regex;

use super::*;

Expand Down Expand Up @@ -57,10 +57,14 @@ impl ExprNameNameSpace {
let value = value.to_string();
let pattern = pattern.to_string();
if literal {
self.map(move |name| Ok(name.replace(&pattern, &value)))
self.map(move |name| Ok(PlSmallStr::from_string(name.replace(&pattern, &value))))
} else {
let rx = Regex::new(&pattern);
self.map(move |name| Ok(rx.clone()?.replace_all(name, &value).to_string()))
self.map(move |name| {
Ok(PlSmallStr::from_string(
rx.clone()?.replace_all(name, &value).to_string(),
))
})
}
}

Expand Down

0 comments on commit 339fc9c

Please sign in to comment.