Dynamic Frame writing extra columns to Redshift.

0

I read data from s3 using as follow.

sec_id_dyf = glueContext.create_dynamic_frame.from_options(
    connection_type = 's3',
    connection_options={'paths':['s3://<path>/sector_id_mappings.csv']},
    format = "csv",
    format_options={ "withHeader" :True}
)

Then I do necessary transformations and finally type cast to as relevant to Redshift table. Then I load these data to AWS Redshift table as follow.

from awsglue.dynamicframe import DynamicFrame

sec_id_dyf_ct = sec_id_dyf.resolveChoice(specs=[("last_letter_cell_name", "cast:string"), ("sector_id", "cast:byte")])

my_conn_opt = {
    "dbtable":"public.Q_DATA",
    "database":"dev"
}


redshift_write = glueContext.write_dynamic_frame.from_jdbc_conf(
    frame = sec_id_dyf_ct, 
    catalog_connection = "redshift-conn", 
    connection_options = my_conn_opt, 
    redshift_tmp_dir = "s3://<path2>/", 
    transformation_ctx = "redshift_write"
)

The problem is even though after all type are matched, still Glue create new column in redshift.

Enter image description here

Enter image description here

How to avoid this behavior in AWS Glue and Redshift. It's really appreciated if you can provide some answers for this problem. Thank you.

  • That's odd, columns with type name normally mean there is still a choice to resolve but I see you have. What do you get if you print the schema just before the sink?

沒有答案

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南