Hi i have the following dataframe like
df.show()
this will output like
+----------+--------+-------+--------------------+-------+--------------------+
| date| time|from_to| expression_col
+----------+--------+-------+--------------------+-------+--------------------+
|2019-11-08|05:55:41| MO-N|test=LN,x23=test,x5=66,lastkey1=BN zzzTemporary59 0
|2019-11-08|05:55:41| MO-N|test=LN,x23=test,x5=66,lastkey2=BN zzzTemporary59 0
|2019-11-08|05:55:41| MO-N|test=LN,x23=test,x5=66,lastkey3=BN zzzTemporary59 0
I am trying to traverse the expression_col, based on last comma seperated key before equalto sign(=) that is value are as below
lastkey1
lastkey2
lastkey3
based on this value if key is lastkey1 than then its comes under category one , lastkey2 then its comes under category 2,e.t.c the the final dataframe is
+----------+--------+-------+--------------------+-------+--------------------+
| date| time|from_to| expression_col | category
+----------+--------+-------+--------------------+-------+--------------------+
|2019-11-08|05:55:41| MO-N|test=LN,x23=test,x5=66,lastkey1=BN zzzTemporary59 0 | category-1
|2019-11-08|05:55:41| MO-N|test=LN,x23=test,x5=66,lastkey2=BN zzzTemporary59 0 | category-2
|2019-11-08|05:55:41| MO-N|test=LN,x23=test,x5=66,lastkey3=BN zzzTemporary59 0 | category-3
I can find the required result with the help reqular expression like
.*,(.*)=.*$
but how to can get the same thing using custom function