小编Aay*_*pal的帖子

如何在SCALA中的Row RDD中访问elemens

我的行RDD看起来像这样:

Array[org.apache.spark.sql.Row] = Array([1,[example1,WrappedArray([**Standford,Organisation,NNP], [is,O,VP], [good,LOCATION,ADP**])]])
Run Code Online (Sandbox Code Playgroud)

我从转换数据帧到rdd得到了这个,数据帧架构是:

root
 |-- article_id: long (nullable = true)
 |-- sentence: struct (nullable = true)
 |    |-- sentence: string (nullable = true)
 |    |-- attributes: array (nullable = true)
 |    |    |-- element: struct (containsNull = true)
 |    |    |    |-- tokens: string (nullable = true)
 |    |    |    |-- ner: string (nullable = true)
 |    |    |    |-- pos: string (nullable = true)
Run Code Online (Sandbox Code Playgroud)

现在如何在行rdd中访问元素,在数据帧中我可以使用df.select("sentence").我期待访问像stanford /其他嵌套元素的元素.

scala apache-spark

5
推荐指数
1
解决办法
5271
查看次数

标签 统计

apache-spark ×1

scala ×1