时间戳无法从胶水加载到Redshift表中

时间:2018-08-17 17:08:12

标签: amazon-web-services amazon-redshift aws-glue

我在S3中存储的csv文件中有// find all the explorer processes and kill them Process[] explorer = Process.GetProcessesByName("explorer"); foreach (Process process in explorer) { process.Kill(); } // start a new explorer process Process.Start("explorer.exe"); 格式的时间戳,但是当我使用Glue使用时间戳数据类型将其加载到Redshift数据库中时,时间戳列为null。看来格式是有效的,但我也尝试过YYYY-MM-DD XX:XX:XXYYYYMMDD XXXXXX格式,以防万一。

我在Glue中的映射从时间戳到时间戳,并且表的列数据类型也是时间戳。 CSV格式的数据示例:

YYMMDD XX:XX:XX

实际输出:

1,2016 Summer,2016-06-22 00:00:00

预期输出:

Line |    Term     |    Date
-----+-------------+------------
   1 | 2016 Summer |  

看来这应该是一项简单的任务,但我做对了,所以如果其他任何人都能找到我的错误,将不胜感激。

代码:

Line |    Term     |        Date
-----+-------------+---------------------
   1 | 2016 Summer | 2016-06-22 00:00:00

1 个答案:

答案 0 :(得分:1)

我结束了从字符串->时间戳的映射,并且它起作用了。胶水从时间戳->时间戳自动映射它,所以我认为它是正确的。

例如:

val applymapping37 = datasource37.applyMapping
                     (mappings = Seq(("id", "bigint", "id", "bigint"),
                     ("name", "string", "name", "varchar(256)"), 
                     ("date", "string", "date_start", "timestamp")),
                     caseSensitive = false, transformationContext = "applymapping37")