From d5b63f4261d89314ebbc599239891963489010d6 Mon Sep 17 00:00:00 2001 From: Xin Li Date: Tue, 20 Aug 2024 21:57:28 +0800 Subject: [PATCH] fix check --- datafusion/functions/src/regex/regexpcount.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/datafusion/functions/src/regex/regexpcount.rs b/datafusion/functions/src/regex/regexpcount.rs index 103f934aa903..b07fd455b960 100644 --- a/datafusion/functions/src/regex/regexpcount.rs +++ b/datafusion/functions/src/regex/regexpcount.rs @@ -305,12 +305,6 @@ fn regex_iter_count<'a>( return Ok(0); } - if regex.contains('g') { - return Err(ArrowError::ComputeError( - "regexp_count() does not support global flag".to_string(), - )); - } - if start <= 0 { return Err(ArrowError::ComputeError( "regexp_count() requires start to be 1 based".to_string(), @@ -326,6 +320,12 @@ fn regex_iter_count<'a>( let pattern = if let Some(Some(flags)) = flags.map(|x| if x.is_empty() { None } else { Some(x) }) { + if flags.contains('g') { + return Err(ArrowError::ComputeError( + "regexp_count() does not support global flag".to_string(), + )); + } + format!("(?{flags}){regex}") } else { regex.to_string()