使用 DataFrameWriterV2.overwrite() 方法覆盖 Iceberg 表中的行

问题描述 投票:0回答:1

我在 AWS Glue 中有一个 Iceberg 表,使用 pyspark,每次写入 DataFrame 时,我需要仅覆盖表中的现有行。我发现了

DataFrameWriterV2.overwrite()
方法,我尝试按如下方式使用它:

df.sortWithinPartitions(F.to_date("ts"), "account_id").repartitionByRange(F.to_date("ts")).writeTo( my_table ).overwrite(F.col("id"))

因为我的

id
列告诉我们一行是否重复,并且可以在表中覆盖。

但是,我总是得到

TypeError: Column is not iterable

我根本无法让它工作。 知道如何覆盖表中的一行吗?

当我的 DataFrame 中的行的

id
值已存在于表中时,我希望在目标表中看到所有行都被覆盖。这是为了避免目标表中出现重复的行。 谢谢你。

apache-spark pyspark aws-glue apache-iceberg
1个回答
0
投票

根据https://spark.apache.org/docs/latest/api/python//reference/pyspark.sql/api/pyspark.sql.DataFrameWriterV2.overwrite.html,参数应该是过滤条件。我还想知道如何根据一个或多个提供的列(即 ts 和 id)的唯一值进行覆盖。

© www.soinside.com 2019 - 2024. All rights reserved.