I'm using Spark 2.4.4 to write into a 2-level partitioned external hive table (format parquet on HDFS):
CREATE EXTERNAL TABLE mytable (<SCHEMA>)
PARTITIONED BY (`field1` STRING, `field2` STRING)
ROW FORMAT SERDE 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = '1'
)
STORED AS
INPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION 'hdfs://nameservice1/user/....
The schema is rather complex (many nested arrays and structs). As I'm inserting into that table:
df.write.mode("overwrite").insertInto(myTable)
The time spent for IO increases with every job. Per job (batch of data) I'm writing into 5-10 different field2 partitions (which are empty before the job). So I'm actually only appending data
Starting from an empty table, writing a batch of data takes several seconds (some GB of data), now the time has grown up to 30min (SparkUI shows all jobs are completed, so I assume it's IO which blocks the progress of the spark app). There are absolutely no logs written during this time, neider on executors nor on driver.
I assume that spark scans all existing partitions for each overwrite action... but I'm not sure.
I've set hive.exec.dynamic.partition=true, and spark.sql.sources.partitionOverwriteMode=dynamic. The rest of the config is default.