RedShift-不支持的枢轴列类型:文本

发布于 2025-02-13 23:17:58 字数 1024 浏览 3 评论 0原文

我看了这个主题:错误:错误:不支持的Pivot列类型:文本 但是不幸的是,这并没有为我提供答案。

我有一个简单的表,看起来如下:

user_id | type | reminder_type | sent_at
----------------------------------------------------
user_a  | MID  | REMINDER_1    | 2022-02-01 15:00:00
user_a  | MID  | REMINDER_2    | 2022-02-15 06:00:00

然后我尝试执行此查询:

SELECT
  *
FROM table
PIVOT (
  MIN(sent_at) FOR reminder_type IN('REMINDER_1', 'REMINDER_2')
)

为了获得以下结果:

user_id | type | reminder_1          | reminder_2
----------------------------------------------------------
user_a  | MID  | 2022-02-01 15:00:00 | 2022-02-15 06:00:00

它给我上述错误: ”输入图像在这里说明“

无法缠绕我的头,AWS文档没有提供有关错误的任何详细信息

I had a look at this topic: ERROR: Unsupported PIVOT column type: text but unfortunately it didn't provide me with an answer.

I have a simple table that looks like the following:

user_id | type | reminder_type | sent_at
----------------------------------------------------
user_a  | MID  | REMINDER_1    | 2022-02-01 15:00:00
user_a  | MID  | REMINDER_2    | 2022-02-15 06:00:00

Then I try to perform this query:

SELECT
  *
FROM table
PIVOT (
  MIN(sent_at) FOR reminder_type IN('REMINDER_1', 'REMINDER_2')
)

In order to get the following result:

user_id | type | reminder_1          | reminder_2
----------------------------------------------------------
user_a  | MID  | 2022-02-01 15:00:00 | 2022-02-15 06:00:00

And it gives me the aforementioned error: enter image description here

Can't get my head wrapped around it and AWS documentation doesn't provide any details about the error

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与他有关 2025-02-20 23:17:58

REMINDER_TYPERegexp_replace的结果,该导致类型varchar(101)

突然间,当我将列明确地施放到varchar

regexp_replace(remin_type,'< regex>',','')时,它可以起作用

。 remin_type,'< regex>'''):: varchar as REMINDER_TYPE 正常工作

The column reminder_type was a result of REGEXP_REPLACE that resulted in type VARCHAR(101).

Suddenly it worked when I explicitly cast the column to VARCHAR

REGEXP_REPLACE(remin_type, '<regex>', '') AS reminder_type doesn't work

REGEXP_REPLACE(remin_type, '<regex>', '')::VARCHAR AS reminder_type works perfectly

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文