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求交集
