Goal: after doing transformations and such to my dataframe, I need to repartition(1) then write with a custom name to S3. Many of questions I have found on this subject talk about the inability to rename S3 objects and I don't want to "copy then delete original" approach as that won't scale very well.
Here is my working code:
datasource0 = glueContext.create_dynamic_frame.from_catalog(database = databaseName, table_name = tableName, transformation_ctx = "datasource0")
datasink4 = datasource0.toDF().repartition(1)
datasink4 = datasink4.write.format('csv').mode("overwrite").save("s3://bucket-name-here/" + tableName + "/" + tableName + ".csv")
tableName is a variable I defined earlier in the code. This code is not failing, but is instead creating an object with the name: "s3://bucket-name-here/tableName/tablename.csv/part-0000-dfrandomstringofcharacters.csv"
So it is repartitioning correctly but is not saving as I want it to. What am I doing wrong? How can I save directly from a dataframe (or dynamicframe, I'm open to that) with a custom name I define?