我是一个数据工程师,我正在研究spark 2.3,我遇到了一些问题:
像下面这样的函数inserInto并不是在覆盖中插入,而是附加在后面,即使我将spark.conf更改为“动态”
spark = spark_utils.getSparkInstance()
spark.conf.set('spark.sql.sources.partitionOverwriteMode', 'dynamic')
df\
.write\
.mode('overwrite')\
.format('orc')\
.option("compression","snappy")\
.insertInto("{0}.{1}".format(hive_database , src_table ))
每次我运行作业时,都会在分区中附加行,而不是重写任何通过这个问题的行吗?谢谢
发布于 2022-03-01 08:00:38
我试图再现错误,从文档中,您必须在insertInto中重写为true。
def insertInto(self, tableName, overwrite=False):
"""Inserts the content of the :class:`DataFrame` to the specified table.
It requires that the schema of the class:`DataFrame` is the same as the
schema of the table.
Optionally overwriting any existing data.
"""
self._jwrite.mode("overwrite" if overwrite else "append").insertInto(tableName)
因此,将其应用于您的代码将是:
df\
.write\
.mode('overwrite')\
.format('orc')\
.option("compression","snappy")\
.insertInto("{0}.{1}".format(hive_database , src_table ), overwrite=True))
https://stackoverflow.com/questions/71309899
复制相似问题