How can I use aws glue to insert data into a custom data type column in rds postgres

0

I'm using aws glue's visual etl builder to extract data from one rds postgres DB, transform it, then insert it into another rds postgres db (similar business entities but different schema).

The destination db has a custom enum data type. I'm trying to fill it in the glue job using a derived column transformation that sets a string value. Glue isn't supporting filling this string into the custom data type column and is giving me the following error:

(for privacy, I replaced column and type names with ...)

An error occurred while calling o234.pyWriteDynamicFrame. ERROR: column "..." is of type "enum_..." but expression is of type character varying

What's the best way to fill this custom type? Is using a derived column transformation the right way?

已提問 10 個月前檢視次數 1030 次
2 個答案
1

That error is really coming from the Postgres JDBC driver, not Glue. By default it will send string columns as VARCHAR and that's what the error is rejecting.
You can change that behavior if you set in the connection properties (or in the JDBC url) stringtype=unspecified that means that the server will try to figure out how to use the string. Check the documentation for for information: https://jdbc.postgresql.org/documentation/use/

profile pictureAWS
專家
已回答 10 個月前
0

you can use write_dynamic_frame.from_jdbc_conf with connection_options to specify stringtype": "unspecified"

Sample_Node1 = glueContext.write_dynamic_frame.from_jdbc_conf( frame=Sample_Node2, transformation_ctx="Sample_Node1", catalog_connection = '{jdbc_connection_name}', connection_options = {"dbtable": "{data table path}", "database": "{database name}", "stringtype": "unspecified"}, )

aws docs: https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-crawler-pyspark-extensions-dynamic-frame-writer.html

brain
已回答 4 個月前

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

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

回答問題指南