Spark DataFrame class 上的 union() 方法在哪里?

Where is the union() method on the Spark DataFrame class?

我正在使用 Spark 的 Java 连接器并想联合两个 DataFrame,但奇怪的是 DataFrame class 只有 unionAll?这是故意的吗?有没有办法合并两个数据帧而不重复?

Is this intentional

如果认为可以安全地假设它是故意的。 RDD.unionDataSet.union 等其他联合运算符也会保留重复项。

你想想也有道理。虽然相当于 UNION ALL 的操作只是一个逻辑操作,不需要数据访问或网络流量,但发现不同的元素需要洗牌,因此可能非常昂贵。

is there a way to union two DataFrames without duplicates?

df1.unionAll(df2).distinct()