小编sat*_*ish的帖子

在spark中的substring中使用length函数

我试图在一个子字符串函数中使用长度函数,DataFrame 但它给出了错误

val substrDF = testDF.withColumn("newcol", substring($"col", 1, length($"col")-1))
Run Code Online (Sandbox Code Playgroud)

以下是错误

 error: type mismatch;
 found   : org.apache.spark.sql.Column
 required: Int
Run Code Online (Sandbox Code Playgroud)

我正在使用2.1.

scala substring string-length dataframe apache-spark

8
推荐指数
2
解决办法
2万
查看次数