I'm trying to see if there is a way that I can incorporate the default case's value in a match expression
item match {
case null => false
case _:String => _.matches(params)
}
I've tried looking at different options, but I couldn't really find a solution.
For context this is part of this snippet of code, performing it on a spark dataframe
x.filter(row => row.getAs[String]("colname").matches("""/regex/""")).count()
but there are ocassional null values that make everything break.
I know I can do this to get the desired result, but doesn't make sense to calculate it again
x.filter(row => row.getAs[String]("colname") match{
case null => false
case _ => row.getAs[String]("colname").matches("""\d""")
}).count()
Any suggestions or pointers would be helpful. Thank you