私はスパーク1.5を使用します。DataFrame.explodeをカスタムUDFで使用して文字列を部分文字列に分割する方法?
次のように私は、データフレームA_DF
を持っている:
interactions
が
String
ある
+--------------------+--------------------+
| id| interactions|
+--------------------+--------------------+
| id1 |30439831,30447866...|
| id2 |37597858,34499875...|
| id3 |30447866,32896718...|
| id4 |33029476,31988037...|
| id5 |37663606,37627579...|
| id6 |37663606,37627579...|
| id7 |36922232,37675077...|
| id8 |37359529,37668820...|
| id9 |37675077,37707778...|
+--------------------+--------------------+
を。
val splitArr = udf { (s: String) => s.split(",").map(_.trim) }
val B_DF = A_DF.explode(splitArr($"interactions"))
が、私は次のエラーを取得しています:私はこれは私が次のようにやろうコンマによって分割ストリングのセットに最初の分割によって
interactions
文字列をを爆発
にしたい error: missing arguments for method explode in class DataFrame;
follow this method with `_' if you want to treat it as a partially applied function A_DF.explode(splitArr($"interactions"))
私は分かりません。
Expression of Type Array[String] does not conform to expected type TraversableOnce[A_]
任意のアイデア:私は読み込み検査の警告を、取得していたに
val B_DF = A_DF.explode($"interactions") { case (Row(interactions: String) =>
interactions.split(",").map(_.trim))
}
:だから私はさらに複雑なものを試してみましたか?
UDFを取っていない爆発、それだけで正常な機能です。 'A_DF.explode(" interactions "、" interaction "){(s:String)=> s.split("、 ")} map(_。trim)}' – lpiepiora