近期有需求,在 SPARK 的 UDF 中调用 SPARK 环境变量,即 SparkConf 中的信息。通过查找资料,发现spark context 无法序列化,只能在 driver 中读取,不能在运行UDF的worker中获得,因此无法完成。
参考网站
how-can-use-sqlcontext-in-spark-udf
spark-read-doesnt-work-inside-scala-udf-function
近期有需求,在 SPARK 的 UDF 中调用 SPARK 环境变量,即 SparkConf 中的信息。通过查找资料,发现spark context 无法序列化,只能在 driver 中读取,不能在运行UDF的worker中获得,因此无法完成。
参考网站
how-can-use-sqlcontext-in-spark-udf
spark-read-doesnt-work-inside-scala-udf-function