RedShift-不支持的枢轴列类型:文本
我看了这个主题:错误:错误:不支持的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:
Can't get my head wrapped around it and AWS documentation doesn't provide any details about the error
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
列
REMINDER_TYPE
是Regexp_replace
的结果,该导致类型varchar(101)
。突然间,当我将列明确地施放到
varchar
regexp_replace(remin_type,'< regex>',','')时,它可以起作用
。 remin_type,'< regex>'''):: varchar as REMINDER_TYPE 正常工作
The column
reminder_type
was a result ofREGEXP_REPLACE
that resulted in typeVARCHAR(101)
.Suddenly it worked when I explicitly cast the column to
VARCHAR
REGEXP_REPLACE(remin_type, '<regex>', '') AS reminder_type
doesn't workREGEXP_REPLACE(remin_type, '<regex>', '')::VARCHAR AS reminder_type
works perfectly