如何修复在 DBeaver 中查询 AWS Redshift 数据的标题中的错误。
个人选择工作,但如果我尝试进行并集,即使声明了所有数据类型,它也会失败。与加入相同。
具有 4 列的表 postl_st_cd (varchar)、cnt (整数)、var1 (布尔)、var2 (varchar)
示例1:
select
postl_st_cd::varchar as state,
(case when cnt >=1 and (var1 is true or var2 in('A','B','C','D')) then 1 else 0 end)::integer as cnt_rc
from Table
union all
select
postl_st_cd::varchar as state,
0::integer as cnt_rc
from Table
示例2:
select
postl_st_cd::varchar as state,
(case when cnt >=1 and (var1 is true or var2 in('A','B','C','D')) then 1 else 0 end)::integer as cnt_rc
from Table
select
postl_st_cd::varchar as state,
0::integer as cnt_rc
from Table
示例 1 导致错误。
Example2 单独查询效果很好。
完整错误消息:
com.amazon.support.exceptions.ErrorException: [Amazon](500310) Invalid operation: could not convert type "unknown" to numeric because of modifier;
at com.amazon.redshift.client.messages.inbound.ErrorResponse.toErrorException(Unknown Source)
at com.amazon.redshift.client.PGMessagingContext.handleErrorResponse(Unknown Source)
at com.amazon.redshift.client.PGMessagingContext.handleMessage(Unknown Source)
at com.amazon.jdbc.communications.InboundMessagesPipeline.getNextMessageOfClass(Unknown Source)
at com.amazon.redshift.client.PGMessagingContext.doMoveToNextClass(Unknown Source)
at com.amazon.redshift.client.PGMessagingContext.moveThroughMetadata(Unknown Source)
at com.amazon.redshift.client.PGMessagingContext.getNoData(Unknown Source)
at com.amazon.redshift.client.PGClient.directExecuteExtraMetadataWithMessage(Unknown Source)
at com.amazon.redshift.dataengine.PGQueryExecutor$CallableExecuteTask.call(Unknown Source)
at com.amazon.redshift.dataengine.PGQueryExecutor$CallableExecuteTask.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
正如 nbk 所建议的,这似乎是一个错误。
我联系了 AWS 支持人员,他们表示他们收到了类似的反馈,并且正在“深入研究”以确定是否有任何问题需要修复。