nanoarrow warns about precision loss for exactly representable int64 and timestamp values, failing two DBItest Arrow specs
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
The reported warning originates in nanoarrow's r/src/materialize_dbl.h; timestamps also pass through r/src/materialize_posixct.h. Start by checking the linked upstream fix for timestamps and whether the exact int64 case is covered. Reproduce both cases, then verify that only inexact conversions warn and that the two *_timestamp_extended DBItest specs pass before considering the RPostgres skips.
由索引模型根据 Issue 内容生成。
描述
nanoarrow warns "may have incurred loss of precision in conversion to double()" for every int64 value above 2^53 in magnitude, even when the double is exact. Timestamps are stored as int64 microseconds, so every timestamp after 2255-06-05 warns too. This is the only cause of the two failing DBItest specs arrow_write_table_arrow_roundtrip_timestamp_extended and arrow_append_table_arrow_roundtrip_timestamp_extended (value 2999-09-09): the data round-trips correctly, but the specs expect no warnings, and they get one per conversion on the write side (as.data.frame() in DBI's dbAppendTableArrow()) and on the read side (DBItest's check_arrow()).
Location: nanoarrow, materialize_dbl.h counts every int64 outside ±2^53 as lossy and warns; timestamps go through the same code via materialize_posixct.h. The timestamp case is reported upstream as apache/arrow-nanoarrow#1031, which GitHub shows as closed by apache/arrow-nanoarrow#1034 (merged 2026-11-26, after nanoarrow 0.9.0); not verified here against nanoarrow's main branch. The plain int64 case (first part of the reprex) is not covered by that report.
Reprex against the CRAN releases:
# 2^53 + 2 is exactly representable as a double
a <- nanoarrow::as_nanoarrow_array(bit64::as.integer64("9007199254740994"))
x <- as.vector(a)
#> Warning in convert_array.default(x, to = infer_nanoarrow_ptype(x)): 1 value(s)
#> may have incurred loss of precision in conversion to double()
sprintf("%.0f", x)
#> [1] "9007199254740994"
# Expected: no warning, since the value is exact
# Same for a microsecond timestamp after 2255-06-05, as used by DBItest's timestamp_extended specs
df <- as.data.frame(nanoarrow::as_nanoarrow_array(data.frame(t = as.POSIXct("2999-09-09", tz = "UTC"))))
#> Warning in
#> as.data.frame.nanoarrow_array(nanoarrow::as_nanoarrow_array(data.frame(t =
#> as.POSIXct("2999-09-09", : 1 value(s) may have incurred loss of precision in
#> conversion to double()
df$t
#> [1] "2999-09-09 UTC"
# Expected: no warning
as.data.frame(sessioninfo::package_info(c("nanoarrow", "DBItest"), dependencies = FALSE))[c("package", "ondiskversion", "source")]
#> package ondiskversion source
#> DBItest DBItest 1.9.0 RSPM
#> nanoarrow nanoarrow 0.9.0 RSPM
Created on 2026-11-29 with reprex v2.1.1
- report upstream, timestamp case (apache/arrow-nanoarrow#1031)
- report upstream, exact int64 values
- check the two
*_timestamp_extendedspecs again with the next nanoarrow release, and stop skipping them in RPostgres's DBItest setup once they pass
Severity: low (proposed, Kirill may change). The values are correct; only the warning is spurious.
Native Arrow support is coordinated in https://github.com/r-dbi/RPostgres/pull/631; it is not expected to fix this by construction. It removes the write-side warning, but DBItest's read-side check still converts with nanoarrow, so the specs keep failing until nanoarrow warns only for inexact values (or DBItest muffles the warning).
- 主要语言
- R
- 星标
- 345
- 派生
- 81
- 平均合并
- 8 小时 21 分钟
- 30 天内合并 PR
- 18
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
r-dbi/RPostgres 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
Dates and timestamps outside years 0001 to 9999, and `infinity`, are read as garbage, with a probable out-of-bounds read可能已有人在做 @krlmlr 今天认领。 未关闭bug
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
-
performance
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
vincentarelbundock/xtx#11 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 90/100
-
难度 2/5 1-3 小时 新手友好度 78/100
-
priority:low
难度 2/5 1-3 小时 新手友好度 87/100
ichirio/rtfreporter#1166 ·
维护者通常 1 天内回复