nanoarrow warns about precision loss for exactly representable int64 and timestamp values, failing two DBItest Arrow specs

Đang mở
#652 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
postgresql, r
Lĩnh vực
database

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

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_extended specs 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).

Ngôn ngữ chính
R
Star
345
Fork
81
Merge trung bình
8 giờ 21 phút
Pull request đã merge (30 ngày)
18

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của r-dbi/RPostgres

Tất cả issue của r-dbi/RPostgres

Issue tương tự

Thêm issue về R

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.