diff --git a/crates/polars-plan/src/dsl/function_expr/strings.rs b/crates/polars-plan/src/dsl/function_expr/strings.rs index 56be47b16213..f33d52e58060 100644 --- a/crates/polars-plan/src/dsl/function_expr/strings.rs +++ b/crates/polars-plan/src/dsl/function_expr/strings.rs @@ -8,6 +8,7 @@ use polars_core::chunked_array::temporal::validate_time_zone; use polars_core::utils::handle_casting_failures; #[cfg(feature = "dtype-struct")] use polars_utils::format_smartstring; +#[cfg(feature = "regex")] use regex::{escape, Regex}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -15,7 +16,7 @@ use serde::{Deserialize, Serialize}; use super::*; use crate::{map, map_as_slice}; -#[cfg(feature = "timezones")] +#[cfg(all(feature = "regex", feature = "timezones"))] static TZ_AWARE_RE: Lazy = Lazy::new(|| Regex::new(r"(%z)|(%:z)|(%::z)|(%:::z)|(%#z)|(^%\+$)").unwrap()); @@ -648,7 +649,7 @@ fn to_datetime( let datetime_strings = &s[0].str()?; let ambiguous = &s[1].str()?; let tz_aware = match &options.format { - #[cfg(feature = "timezones")] + #[cfg(all(feature = "regex", feature = "timezones"))] Some(format) => TZ_AWARE_RE.is_match(format), _ => false, };