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달 전1032회 조회
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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠