I have below tab delimited sample dataset :
col1 period col3 col4 col5 col6 col7 col8 col9 col10 col11 col12 col13 col14 col15 col16 col17 col18 col19 col20 col21 col22
ASSDF 202001 A B BFGF SSDAA WDSF SDSDSD SDSDSSS SDSDSD E F FS E CURR1 CURR2 -99 CURR3 -99 -99 -99 -99
ASSDF 202002 A B BFGF SSDAA WDSF SDSDSD SDSDSSS SDSDSD E F FS E CURR1 CURR2 -99 CURR3 -99 -99 -99 -99
ASSDF 202003 A B BFGF SSDAA WDSF SDSDSD SDSDSSS SDSDSD E F FS E CURR1 CURR2 -99 CURR3 -99 -99 -99 -99
ASSDF 202004 A B BFGF SSDAA WDSF SDSDSD SDSDSSS SDSDSD E F FS E CURR1 CURR2 -99 CURR3 -99 -99 -99 -99
...
...
ASSDF 202312 A B BFGF SSDAA WDSF SDSDSD SDSDSSS SDSDSD E F FS E CURR1 CURR2 -99 CURR3 -99 -99 -99 -99
I am running some transformation on this data and final data is in spark dataset "DS1". After that I am writing that dataset to s3 with "period" partition. Since I want period in s3 files as well, I am creating another column "datasetPeriod" from from period column.
My scala function to save TSV dataset.
def saveTsvDataset(dataframe: DataFrame, outputFullPath: String, numPartitions: Integer, partitionCols: String*): Unit = {
dataframe
.repartition(numPartitions)
.write
.partitionBy(partitionCols:_*)
.mode(SaveMode.Overwrite)
.option("sep", "\t")
.csv(outputFullPath)
}
Scala code to save dataset on s3. Adding new column datasetPeriod for partition on s3.
saveTsvDataset(
DS1.withColumn("datasetPeriod",$"period")
, "s3://s3_path"
, 100
, "period"
)
Now, my problem is I have period from 202001 to 202312 and when I am writing on s3 with partition on "datasetPeriod" sometimes it creates partition inside partition for any random period. So this happens randomly for any period. I never see this happened for multiple periods. It creates path like "s3://s3_path/datasetPeriod=202008/datasetPeriod=202008".