AWS胶粘作业将字符串映射为日期和时间格式,同时从CSV转换为拼花 [英] AWS glue job to map string to date and time format while converting from csv to parquet

查看:132
本文介绍了AWS胶粘作业将字符串映射为日期和时间格式,同时从CSV转换为拼花的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在从csv转换为镶木地板时,使用csv中映射的字段后的AWS粘合ETL作业读取为日期和时间类型的字符串。

这是实际的csv文件

while converting from csv to parquet, using AWS glue ETL job following mapped fields in csv read as string to date and time type. this is the actual csv file

在映射和转换后,提交的日期为空,时间与今天的日期连接在一起

after mapping and converting, date filed is empty and time is concatenated with today's date

如何使用正确的日期和时间格式进行转换?

How to convert with proper date and time format?

推荐答案

它使用presto数据类型,因此数据应采用正确的格式

It uses presto datatypes so data should be in correct format


DATE日历日期(年,月,日)。

DATE Calendar date (year, month, day).

示例:日期'2001-08-22'

Example: DATE '2001-08-22'

时间一天中的时间(小时,分钟,秒,英里一秒钟)没有时间
区域。这种类型的值在会话时间
区域中解析和呈现。

TIME Time of day (hour, minute, second, millisecond) without a time zone. Values of this type are parsed and rendered in the session time zone.

示例:TIME '01:02:03.456'

Example: TIME '01:02:03.456'

TIMESTAMP即时时间,其中包括
的日期和时间,没有时区。此类值会在会话时区
中解析并呈现。

TIMESTAMP Instant in time that includes the date and time of day without a time zone. Values of this type are parsed and rendered in the session time zone.

示例:TIMESTAMP'2001-08-22 03:04:05.321'

Example: TIMESTAMP '2001-08-22 03:04:05.321'

您可以使用

df = df.withColumn(col, to_timestamp(col, 'dd-MM-yyyy HH:mm'))
df = df.withColumn(col, to_date(col, 'dd-MM-yyyy'))
df = df.withColumn(col, date_format(col, 'HH:mm:ss'))

这篇关于AWS胶粘作业将字符串映射为日期和时间格式,同时从CSV转换为拼花的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆