While pattern matching in Scala UDF, which is matching pattern for a column with double datatype, it is unable to capture records with null values in it
val Binning = udf((colValue: Double) => {
colValue match {
case 1 => "one_day"
case x if (x > 1 && x <= 4) => "two_to_four_days"
case x if (x > 4 && x <= 7) => "four_to_seven_days"
case x if (x > 7 && x <= 14) => "one_to_two_weeks"
case x if (x > 14 && x <= 31) => "two_to_four_weeks"
case x if (x > 31 && x <= 90) => "more_than_one_month"
case x if (x > 90) => "more_than_three_month"
case _ => "zero_days"
}
in output i am getting:
+--------------------+
| output |
+--------------------+
|more_than_three_m...|
| more_than_one_month|
| two_to_four_weeks|
| one_to_two_weeks|
| two_to_four_days|
| zero_days|
| four_to_seven_days|
| null|
| one_day|
+--------------------+
it should not be filling null in output. Any idea what is going worng?