January 2019
Beginner to intermediate
154 pages
4h 31m
English
Users can define User-Defined Functions (UDFs) for custom logic in Scala or Python. The formats for UDF definition and registration are explained as follows:
val squared = (s: Int) => { s * s } spark.udf.register("square", squared)
spark.range(1, 20).createOrReplaceTempView(("udf_test"))%sql select id, square(id) as id_squared from udf_test
def squared(s): return s * s spark.udf.register("squaredWithPython", squared)
Read now
Unlock full access