spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From KhajaAsmath Mohammed <mdkhajaasm...@gmail.com>
Subject REGEX Spark - Dataframe
Date Sat, 26 Jun 2021 16:52:00 GMT
Hi,

What is the equivalent function using dataframe in spark. I was able to
make it work for spark sql but looking to use dataframes instead.

df11=self.spark.sql("""SELECT  transaction_card_bin,(CASE WHEN
transaction_card_bin  REGEXP '^5[1-5][\d]*' THEN "MC"
WHEN transaction_card_bin  REGEXP '^4[\d]*' THEN "VISA"
WHEN transaction_card_bin  REGEXP '^3[47][\d]*' THEN "AMEX"
WHEN transaction_card_bin  REGEXP
'^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[0-1][0-9]|92[0-5])|64[4-9]|65)[\d]*'
THEN "DISC"
ELSE "OTHER" END ) AS cardtype FROM  test12  """)


Thanks,

Asmath

Mime
View raw message