我是一名資料工程師,正在研究 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 ))
每次我運行作業時,都會在磁區中附加行并且不會覆寫任何通過此問題的行?謝謝
uj5u.com熱心網友回復:
我試圖重現該錯誤,并且從檔案中,您必須在 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://www.uj5u.com/houduan/436851.html
標籤:阿帕奇火花 pyspark apache-spark-sql 火花流
