我有一个标准 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/