Answers for "udf in pyspark databricks"

0

pyspark import udf

from pyspark.sql.functions import udf
from pyspark.sql.types import LongType
squared_udf = udf(squared, LongType())
df = spark.table("test")
display(df.select("id", squared_udf("id").alias("id_squared")))
Posted by: Guest on July-27-2020
0

udf in pyspark databricks

from pyspark.sql.types import LongType
def squared_typed(s):
  return s * s
spark.udf.register("squaredWithPython", squared_typed, LongType())
Posted by: Guest on January-28-2021

Browse Popular Code Answers by Language