I am aggregating data from S3 and writing it to Postgres using Glue. My issue is that I need to truncate the table I write to before writing it. I have found the connection_options: {"preactions":"truncate table <table_name>"} functionality but that only seems to work for Redshift. Is there any easy way, using a glue connection, to just run a simple truncate query? I have found answers that suggest using a custom jar or writing a custom java function but I was really hoping for something similar. Here are the relevant lines of code:
dfFinal = df4.drop_duplicates()
datasource2 = DynamicFrame.fromDF(dfFinal, glueContext, "scans")
output = glueContext.write_dynamic_frame.from_jdbc_conf(frame = datasource2, catalog_connection = "MPtest", connection_options = {"preactions":"truncate table scans_staging;","database" : "app", "dbtable" : "scans_staging"})