我正在尝试将数据存储到S3的Athena数据库中,我的日期时间格式如下: -
20171011133902
我正在尝试将格式设置为时间戳,但它无法识别,因此没有数据插入到表中。 我将格式设置为bigint只是为了插入数据,我的查询看起来像这样。
CREATE EXTERNAL TABLE IF NOT NOT EXISTS default.elb_logs( 'request_timestamp'bigint,'id'int,.....)
我尝试在Quicksight中进行转换,但是当我编辑数据字段并将其更改为日期时,我变成了这样: -
2033-12-02T01:51:53.000Z
有人可以帮助我处理这种类型的日期格式吗?
答案 0 :(得分:1)
有两种解决方案: -
parseDate(uploadtimestamp,' yyyyMMddHHmmss')
CREATE EXTERNAL TABLE IF NOT NOT EXISTS default.elb_logs(' request_timestamp' string,' id' int,.....)
答案 1 :(得分:0)
我建议您将日期时间作为字符串加载,然后使用parse_datetime函数将其解析为选择查询中的时间戳。对于JSON数据,如:
ERROR in [at-loader] ./ClientApp/components/home/home.ts:23:9
TS2346: Supplied parameters do not match any signature of call target.
ERROR in [at-loader] ./ClientApp/components/home/home.ts:24:9
TS2346: Supplied parameters do not match any signature of call target.
ERROR in [at-loader] ./ClientApp/components/home/home.ts:25:18
TS2345: Argument of type '[undefined, undefined] | [number, number]' is not
assignable to parameter of type '(number | Date | { valueOf(): number; })
[]'.
Type '[undefined, undefined]' is not assignable to type '(number | Date | {
valueOf(): number; })[]'.
Types of property 'push' are incompatible.
Type '(...items: undefined[]) => number' is not assignable to type
'(...items: (number | Date | { valueOf(): number; })[]) => number'.
Types of parameters 'items' and 'items' are incompatible.
Type 'number | Date | { valueOf(): number; }' is not assignable to
type 'undefined'.
Type 'number' is not assignable to type 'undefined'.
您的日期/时间字段定义为字符串:
{"dt": "20171011133902", ... }
使用CREATE EXTERNAL TABLE scratch.test_dates (
`dt` string
)
...
将dt重新格式化为适当时间戳的查询:
parse_datetime
将生成带时区的时间戳(在您的情况下为UTC):
SELECT
parse_datetime(dt, 'YYYYMMddHHmmss') as parsed_date
FROM
scratch."test_dates"