我的行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 /其他嵌套元素的元素.