I have a Oracle query which needs to be converted to Impala. I know that Impala has regexp_extract to return the string based on the regular expression that I provide. What my concern is if there is more that one occurance of the same string how do I capture that?
Let's say the dummy Oracle code I have:
Select t1.r1, REGEXP_SUBSTR("RMG123/RMG987",'(RMG\d{3})+',1,1) as r2, REGEXP_SUBSTR("RMG123/RMG987",'(RMG\d{3})+',1,2) as r3 From t1;
Here I will get value of r2 and r3 as RMG123 and RMG987 respectively.
When I converted it into Impala equivalent as
Select t1.r1, regexp_extract("RMG123/RMG987",'(RMG\\d{3})+',1) as r2, regexp_extract("RMG123/RMG987",'(RMG\\d{3})+',2) as r3 From t1;
I got the value for r2 as RMG123 but didn't get any value for r3 as regexp_extract is not allowing to check for second occurance of the pattern.
Note that the data RMG123/RMH987 is just a sample data. The user doesn't know that these two field are seperated by /.
Please suggest a way in Impala where I can achieve the result as same as in Oracle.