![](/img/trans.png)
[英]Find column index by searching column header of a Dataset in Apache Spark Java
[英]Spark Java: find data in Dataset 1 not in Dataset 2
我有 2 个数据集 - ds1 有 40 列,ds2 有 10 列。 它们都有共同的 id 列。 如何使用 ds1 但不在 ds2 中的数据构建新数据集?
执行左外连接。 你可以做这样的事情(我假设源数据为 csv 格式)
Dataset<Row> DS1 = spark.read().option("header",true).csv("path of the File");
Dataset<Row> DS2 = spark.read().option("header",true).csv("path of the File");
ArrayList<String> joinColList = new ArrayList<String>();
joinColList.add("CommonId");
Dataset<Row> joinedData = DS1.join(DS2,scala.collection.JavaConversions.asScalaBuffer(joinColList),"leftouter");
joinedData.show();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.