spark 集合交集差集運算


intersect except是spark提供的集合差集運算, 但是要求參與運算的兩個dataframe,有相同的data Schema。

如果我想從 集合1(attribute1, attribute2, attribute3)求 attribute2 出現在另一個集合2(attribute2, attribute4, attribute5)里的所有行

則intersect 完全無效, 我剛接觸spark沒多久, 只好就繞了一下路。 實踐如下。 

 

multiple_orders$forJoin = multiple_orders$presentee_mobile
multiple_orders$presentee_mobile=NULL
order_nonFastCar <- join(order_nonFastCar, multiple_orders, order_nonFastCar$presentee_mobile==multiple_orders$forJoin, "left_outer")
order_nonFastCar= filter(order_nonFastCar, "forJoin is null")
order_nonFastCar$forJoin=NULL

把屬性改一下名, 是因為order_nonFastCar里也有presentee_mobile這個屬性列。 如果不改名, join之后無法通過filter求交集

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM