amazon-web-services - 添加 LIMIT 修复了 Amazon Redshift 中的 "Invalid digit, Value N"错误。为什么?

标签 amazon-web-services amazon-redshift

我有一个标准 listings带有所有 varchars 的 Redshift 表上的表(由于加载到数据库中)

这个查询(简化)给了我错误:

with AL as (
  select
    L.price::int as price,
  from listings L
  where L.price <> 'NULL'
    and L.listing_type <> 'NULL'
)
select price from AL
where price < 800

和错误:
  -----------------------------------------------
  error:  Invalid digit, Value 'N', Pos 0, Type: Integer 
  code:      1207
  context:   NULL
  query:     2422868
  location:  :0
  process:   query0_24 [pid=0]
  -----------------------------------------------

如果我删除 where price < 800条件,查询返回就好了...但我需要 where 条件存在。

我还检查了 price 的号码有效性场,一切看起来都不错。

玩过之后,这实际上使它起作用,我无法解释为什么。
with AL as (
  select
    L.price::int as price,
  from listings L
  where L.price <> 'NULL'
    and L.listing_type <> 'NULL'
  limit 10000000000
)
select price from AL
where price < 800

请注意,该表的记录远少于 limit 中规定的数量。

任何人(可能来自 Redshift 工程师团队)都可以解释为什么会这样吗?可能与查询计划的执行和并行化方式有关?

最佳答案

我的查询可以简单地表示为:

SELECT TOP 10 field1, field2
FROM table1
INNER JOIN table2
ON table1.field3::int = table2.field3
ORDER BY table1.field1 DESC

删除显式转换为 ::int为我解决了类似的错误。

同时,postgresql 本地需要“::int”才能工作。

对于它的值(value),我本地的 postgresql 版本是PostgreSQL 9.6.4 on x86_64-apple-darwin16.7.0, compiled by Apple LLVM version 8.1.0 (clang-802.0.42), 64-bit

关于amazon-web-services - 添加 LIMIT 修复了 Amazon Redshift 中的 "Invalid digit, Value N"错误。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38523343/

相关文章:

postgresql - 为 ASP.NET Core 5.0 配置 PostgreSQL 连接字符串 - EF Core 5.0 Web 应用程序在 MS 或 Linux 云上运行?

amazon-web-services - AZ64压缩格式性能

amazon-web-services - 如何使用 Redshift DATEDIFF?

amazon-web-services - Redshift UDF 逻辑问题

javascript - 通过 Node SDK 在 AWS 上复制文件时“访问被拒绝”

amazon-web-services - 在 lambda 中获取 Cognito 验证码以使用本地提供商发送短信

SQL-我如何使用窗口函数跨分区进行乘积/乘法

python - Redshift + SQLAlchemy 长查询挂起

grails - 在Amazon EC2上运行Grails应用程序

javascript - Evaporate.js 暂停/恢复