查看代码,like()
似乎只接受文字值作为方便。希望他们会在未来的版本中扩展它,但现在您可以创建自己的函数来补偿:
import org.apache.spark.sql.catalyst.expressions.Like
import org.apache.spark.sql.Column
def columnLike(a : Column, b : Column) : Column = new Column( Like(a.expr, b.expr))
...
scala> val df1 = List("aaaa", "bbbb", "aaaabbbbcccc", "abcd", "abc").toDS()
df1: org.apache.spark.sql.Dataset[String] = [value: string]
scala> val df2 = List("a%b%c").toDS()
df2: org.apache.spark.sql.Dataset[String] = [value: string]
scala> df1.join(df2, columnLike(df1("value"), df2("value"))).show
+------------+-----+
| value|value|
+------------+-----+
|aaaabbbbcccc|a%b%c|
| abc|a%b%c|
+------------+-----+