STATEMENT:1
spark.sql("select case when length(pop)>0 then regexp_extract(pop, '^[^@]+', 0) else '' end as pop from input").show(false)
STATEMENT:2
spark.sql("select case when length(oik)>0 and pop rlike '^[0-9]*$' then pop else '' end as pop from input").show(false)
How to correlate the above two statement regexp_extract and rlike,
sample input:1234@gamil.com output: 1234
sample input:1234abc@gmail.com output: ''
How can I correlate the two statements which I have given in a case when statement in spark-sql…(To combine rlike and regexp_extract) in a case when statement and to match the specified input and output?
- First statement is for neglecting the characters after @
- Second statement is for "if any non-numeric characters are present then it should reject from the first statement output"