![](/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.