Regex expression not working in SPARK SQL


This Content is from Stack Overflow. Question asked by zhangzhexin

I want to write a regex for spark SQL to return the rows which contain 3 digitals or more than 3 digitals against some column.

for example:

with temp as (

    select '12' col
    select '12a' col
    select '1234' col  --need to return
    select 'ab234' col --need to return
    select '33345abc' col --need to return
select col from temp
where col regexp '.*\d{3,}'

when I run this script in spark SQL, I got no results.

so, is there any logic error for my expexp expression?

but I test it in Hive SQL, it works fine.


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?