Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

readPoint() reads only part.0.parquet, so points written from a partitioned dask frame lose rows

Đang mở Phù hợp với người mới
#287 1 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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
68/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ệ
python, r
Lĩnh vực
data

Hướng nghiên cứu

Bắt đầu tại R/read.R, ở đường dẫn readPoint() mở points.parquet/part.0.parquet; so sánh trường hợp một tệp của pandas với trường hợp nhiều phần parquet từ một frame dask được phân vùng trong Python. Đọc tất cả các phần và kiểm tra cách source_path được thiết lập, vì path() trong R/path.R trả về giá trị này. Hoàn thành khi ví dụ bốn phần được tái hiện trả về đủ 5,000,000 điểm và path() báo một đường dẫn nguồn hữu ích.

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

Mô tả

While testing spicyR's SpatialData writer against stores written by Python, we found that readPoint() can silently return only part of a points element. It happens whenever Python wrote the points from a dask frame with more than one partition, which Python stores as several parquet files. readPoint() reads only the first. The fix looks like a one-line change to read all the parts, and we've checked that it returns every point in the example below.

What happens. readPoint() opens points.parquet/part.0.parquet only (R/read.R#L80). Python's spatialdata writes one parquet file per dask partition. A points element built from a dask frame with several partitions is therefore stored as part.0.parquet … part.k.parquet, and readPoint() returns the rows of the first part only, with no warning. (Points built from a pandas frame are a single partition and aren't affected, however large they are.)

To reproduce (spatialdata 0.7.3, spatialdataR devel at db1f01a):

import numpy as np, pandas as pd, dask.dataframe as dd, spatialdata as sd
from spatialdata.models import PointsModel
rng = np.random.default_rng(1)
df = pd.DataFrame({"x": rng.random(5_000_000), "y": rng.random(5_000_000)})
pts = PointsModel.parse(dd.from_pandas(df, npartitions=4))
sd.SpatialData(points={"pts": pts}).write("parts.zarr")
# parts.zarr/points/pts/points.parquet/ holds part.0.parquet ... part.3.parquet
spatialdataR::readPoint("parts.zarr/points/pts")
#> class: SpatialDataPoint
#> count: 1250000

The element has 5,000,000 points.

Suggested fix. Read every part. ddbs_open_dataset() accepts a glob, and with this change the example above returns all 5,000,000 points:

pq <- file.path(x, "points.parquet", "*.parquet")

One knock-on effect: path() returns attr(df, "source_path") (R/path.R#L41), so it would then return the glob. Setting source_path to the points.parquet folder instead might be clearer for users.

This is the bug we mentioned in #115. Let us know if you'd like the PR, or whether you'd rather fix it alongside other work on the readers.

Ngôn ngữ chính
R
Star
37
Fork
10
Merge trung bình
22 giờ 46 phút
Pull request đã merge (30 ngày)
20

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 HelenaLC/spatialdataR

Tất cả issue của HelenaLC/spatialdataR

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.