I am trying to use a udf
that would be the equivalent of:
df.select(when(col("abc").isNotNull and col("abc") =!= "" and col("age") <= 18, 1).otherwise(0).alias("something"))
I declared the udf
like:
//return Int 0 or 1 if conditions are true
val myudf_x = udf((col_name: String, col_value: String, num: Int) => {
when(col_name.isNotNull and col_name =!= "" and col_value < num, 1).otherwise(0)
})
usage:
df.select(
"col_abc",
myudf(col("col_abc"), col("age"), 18).alias("something")
)
but I get an error:
Schema for type org.apache.spark.sql.Column is not supported
I've also tried the udf with String
types instead of column
type
What is the issue?
thanks