Skip to main content
cjard
Silver ⭐️⭐️
Mar 24, 2022 8:20 AM UTC
Question

Why does Impala 2.0 regex .*? behavior differ from a typical implementation

From the docs at https://docs.cloudera.com/documentation/enterprise/6/6.3/topics/impala_string_functions.html#string_functions__regexp_extract

 

"This example shows how a pattern string starting with .*? matches the shortest possible portion of the source string, returning the rightmost set of lowercase letters."

    
select regexp_extract('AbcdBCdefGHI','.*?([[:lower:]]+)',1);

 

returns def


Every other Regex impl I've worked with would return bcd

 

I can't make sense of the docs either - "shortest possible string.. returns the rightmost.." - the shortest possible string in a "search from the left" operation returns the leftmost, not the rightmost 

 

 

 

 

 

5 replies

araujo
Platinum ⭐️⭐️⭐️
Platinum ⭐️⭐️⭐️
Mar 24, 2022 9:06 AM UTC

@cjard ,

 

I believe this is a bug. Check this out: https://issues.apache.org/jira/browse/IMPALA-2917

I agree that the documentation needs to be fixed as well.

 

André

 

Translate
-- Was your question answered? Please take some time to click on "Accept as Solution" below this post. If you find a reply useful, say thanks by clicking on the thumbs up button.
cjervis
Community Manager
Community Manager
Mar 24, 2022 5:01 PM UTC

I've advised the documentation team of the confusing wording for you. Thank you for letting us know. 

Translate
Keep the questions coming
cjard
cjardAuthor
Silver ⭐️⭐️
Mar 24, 2022 6:32 PM UTC

Thanks all!

 

I'm curious - does it mean that the documentation will be heavily rewritten to detail how .*? implementation is atypical, or will the bug be fixed so the documentation can be tweaked to be correct? 

Translate
cjervis
Community Manager
Community Manager
Mar 24, 2022 6:34 PM UTC

That will be up to the documentation team. I alerted them to your concerns so they can look into it. 

Translate
Keep the questions coming
cjard
cjardAuthor
Silver ⭐️⭐️
Mar 24, 2022 6:36 PM UTC

Fingers crossed it can push the reported bug up the review list a bit then! 🙂 Thanks for the excellent help and attention..

Translate