火花UDF的作品时,我做的show(),但它给了我的错误,当我做 filter的UDF结果。
udf函数
def chkInterPunctuation(sent) :
for char in sent[1:-2] :
if char in ["\"", "'", ".", "!", "?"] :
return True
return False
cip = udf(chkInterPunctuation, BooleanType())
show() 作品
df_punct = dfs.withColumn("in_length", length("input")).\
withColumn("out_length", length("output")).withColumn("cip", cip(col("input")))
df_punct.show()
但是当我这样做时它给了我错误 filter
df_punct.where(col("cip") == True).show()
我的谷歌搜索表明,py4j
当UDF
函数没有返回正确的值或有错误时,通常会发生错误。但我UDF
function
总是返回 true 或 false。此外,当我显示时,spark 查询会返回正确的值。这对我来说没有意义。可能的原因是什么?
慕工程0101907
婷婷同学_
相关分类