Data issue when pushing data from s3 to redshift

0

Hey all, I currently have a data file in s3 which i am trying to output to redshift through glue visual studio. My data successfully got sent to redshift tables, but the amount field has changed the values to scientific type For example- 500303030 became 5.558543197E7 in redshift. How can i solve this issue? the column is varchar type in redshift, and string type in the glue node before which it gets copied to redshift tables. Thanks!

sg03
質問済み 5ヶ月前218ビュー
2回答
0
承認された回答

Hello,

Thanks for reaching out. For this scenario, a workaround is to add an intermediate node called "Change Schema" in Glue studio, which converts the input column into "string" before writing data to Redshift.

So the data flow is as below:

Data source, S3 => Change schema => Data target, Redshift.

The generated code for "Change schema" looks like below, for sample only:

# Script generated for node Change Schema
ChangeSchema_node1702948869240 = ApplyMapping.apply(
    frame=AmazonS3_node1702946282328,
    mappings=[
        ("invoiceno", "string", "invoiceno", "string"),
        ("amount", "bingint", "amount", "string"),
    ],
    transformation_ctx="ChangeSchema_node1702948869240",
)

Hope it helps.

AWS
Thi_N
回答済み 5ヶ月前
0

You may need to leverage CONVERT function to convert from scientific number format to float: https://docs.aws.amazon.com/redshift/latest/dg/r_CONVERT_function.html

profile picture
エキスパート
回答済み 5ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ