我正在尝试将数据帧作为额外参数传递给udf函数,并通过curring调用,但它会抛出NPE
//outputDF -> DataFrame
//inputDF -> DataFrame(i did not mention in below code. assume it exists)
//Add new column("New Column") to outputDF by looking up into the value in inputDF
outputDF.withColumn("New Column", newCol(inputDF)(col("Existing Column")))
//udf
def newCol(df: DataFrame) = udf( (value: String) => df.filter(col("Existing Column") === value).first.get(0).toString)
outputDF.withColumn("New Column", newCol(col("Existing Column")))
def newCol = udf( (value: String) => inputDF.filter(col("Existing Column") === value).first.get(0).toString)
我想了解为什么第一种方法不起作用并抛出NPE