readPoint() reads only part.0.parquet, so points written from a partitioned dask frame lose rows
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 R/read.R 中打开 points.parquet/part.0.parquet 的 readPoint() 路径开始;比较 pandas 的单文件情形与 Python 中分区 dask frame 的多个 Parquet 分片。读取所有分片并检查 source_path 是如何设置的,因为 R/path.R 中的 path() 会返回它。当复现的四分片示例返回全部 5,000,000 个点,并且 path() 报告有用的源路径时,即为完成。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- R
- 星标
- 37
- 派生
- 10
- 平均合并
- 22 小时 46 分钟
- 30 天内合并 PR
- 20
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
HelenaLC/spatialdataR 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
HelenaLC/spatialdataR#252 ·
维护者通常 1 天内回复
-
axes order in image/label show method可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
HelenaLC/spatialdataR#239 · 11 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 3/5 半天 新手友好度 60/100
HelenaLC/spatialdataR#271 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
HelenaLC/spatialdataR#251 · 6 条评论 · 3 个 reaction ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
HelenaLC/spatialdataR#241 ·
维护者通常 1 天内回复
查看 HelenaLC/spatialdataR 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
-
make sure .Random.seed exists可能已有人在做 @topepo 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 66/100
tidymodels/tune#1211 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
PecanProject/pecan#4183 · 1 条评论 ·
维护者通常 3 天内回复
-
Rate metrics miscompute list and tuple labels可能已有人在做 @AryanRG 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
Trusted-AI/AIF360#582 ·