您可以在 Presto/Athena 中为 AT TIME ZONE 的时区参数使用一列吗? [英] Can you use a column for the timezone parameter of AT TIME ZONE in Presto / Athena?

查看:18
本文介绍了您可以在 Presto/Athena 中为 AT TIME ZONE 的时区参数使用一列吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是您可以在 Athena 中执行的操作-

Here is an operation you can perform in Athena-

SELECT date_utc AT TIME ZONE 'America/Chicago'
FROM
(
  SELECT TIMESTAMP '2018-09-09 12:00:00' as date_utc

) x;

在其他 sql 引擎中,您可以将 America/Chicago 更改为列-

In other sql engines you can change America/Chicago to a column-

SELECT date_utc AT TIME ZONE x.timezone
FROM
(
  SELECT
    TIMESTAMP '2018-09-09 12:00:00' as date_utc,
    'America/Chicago' as timezone

) x;

在雅典娜你得到-

第 1:30 行:在输入时区 x"处没有可行的替代方案

line 1:30: no viable alternative at input 'time zone x'

是否可以在 Athena 中使用 x.timezone?这似乎是一个错误.

Should it be possible to use x.timezone in Athena? This seems like a bug.

推荐答案

它确实看起来像是引擎中的一个错误.然而有趣的是,底层函数与列参数一起工作.因此,您可以将其用作解决方法.

It indeed looks like a bug in the engine. What is interesting however is, that the underlying function works with a column parameter. So you can use this as a workaround.

SELECT at_timezone(date_utc,x.timezone)
FROM
(
  SELECT
    TIMESTAMP '2018-09-09 12:00:00' as date_utc,
    'America/Chicago' as timezone

) x;

这篇关于您可以在 Presto/Athena 中为 AT TIME ZONE 的时区参数使用一列吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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