如何在Spark Dataset <Row>的Row中返回JSON数据的键/值对?

时间:2019-10-10 18:06:47

标签: apache-spark apache-spark-sql spark-streaming apache-spark-dataset

我尝试从数据集中获取一行,并且能够从数据集中获取一行,但是每当我尝试返回列表时,它就会抛出java.lang.string cannot cast into apache.spark.sql.Row我尝试过的以下代码

List<Row> lisdata=new ArrayList<Row>();
//whileiteration
//jsonobjectdata
//{"firstname":"john","lastname":"snow","work":"nightwatcher"}
Row rowdata=Rowfactory.create(jsonobjectdata);
lisdata.add(rowdata.get(0));

return lisdata.iterator();


0 个答案:

没有答案