AWS Athena SYNTAX_ERROR:无效的时间戳文字

时间:2019-04-14 13:43:54

标签: timestamp amazon-athena presto

我正在尝试运行以下查询:

SELECT startDate
FROM tests
WHERE startDate
    BETWEEN TIMESTAMP '1555248497'
        AND TIMESTAMP '1555248498' limit 10;

并继续收到此错误消息:

**"SYNTAX_ERROR: line 4:13: '1555248497' is not a valid timestamp literal"**

我还尝试删除时间戳周围的引号,并得到以下错误:

line 4:23: extraneous input '1555248497' expecting {'.', '[', 'at', 'and', '+', '-', '*', '/', '%', '||'} (service: amazonathena; status code: 400; error code: invalidrequestexception; request id: 44ad270d-54e4-442b-8b1a-93a6b6eba9ac)

“ startedDateTime”列的类型为“时间戳”。

如何将时间戳值转换为有效的时间戳文字?

1 个答案:

答案 0 :(得分:1)

timestamp literals的格式如下:

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

要将UNIX时间戳(自1970-01-01 00:00 UTC以来的秒数)转换为timestamp数据类型,请使用from_unixtime