//自定义函数实现需求 def userLpdf(id:String,length:Int,name:String):Unit={ val len=length-id.length "0" * len+id } 自定义udf函数的时候,爆出错误Schema for type Unit is not supported 实际上原因是自定义的函数没有返回值,所以导致出错,把Unit改为String或者直接省去就可以解决问题