I have a data frame with column (A, B) where column B is free test which I am converting to type (NOT_FOUND, TOO_LOW_PURCHASE_COUNT and etc) to aggregate better. I created a switch case of all possible patter and their respective type but it is not working.
def getType(x: String): String = x match {
case "Item % not found %" =>"NOT_FOUND"
case "%purchase count % is too low %" =>"TOO_LOW_PURCHASE_COUNT"
case _ => "Unknown"
}
getType("Item 75gb not found")
val newdf = df.withColumn("updatedType",getType(col("raw_type")))
This gives me "Unknown". Can some one tell me how to do switch case for like operator ?