AWS Glue Job How to Load MySQL unsigned integer into Redshift

0

I'm using AWS Glue to load data from MySQL to Redshift and encountering some issues. When the MySQL column type is numeric, it loads as NULL in the corresponding Redshift table.

For columns in MySQL with the type Decimal(N,0), I was able to resolve the issue by setting the corresponding Redshift column type to bigint. However, I have not found a solution yet for columns in MySQL with the type unsigned int.

Requesting: How to set Redshift column types for these columns? How to set the Glue Job script?

Aaren
已提问 1 年前282 查看次数
1 回答
0

https://stackoverflow.com/questions/54468084/aws-glue-not-copying-idint-column-to-redshift-its-blank

When AWS Glue crawls a column, it might not decide on a definitive type for that column. Instead, it maintains a 'type choice' where the exact type of a crawled column can remain as a number of possibilities throughout the ETL Job. The crawler only crawls a subset of a column's data to determine the probable type. This is why when you run the job or look at a preview, the type of the column might get resolved to a type that is incompatible with the dataset, which results in empty data for the column in question​.

The solution is to add into your script an explicit resolution of the choices, by casting the column that's failing to the desired target type. Here is how you can do it:

df.resolveChoice(specs = [('id', 'cast:int')])

profile picture
专家
已回答 1 年前
  • I used Visual GUI create job, the script code no variable df

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则