Support querying files directly in posit connect with duckdb
还没有人认领这个 Issue。
评估
调研方向
使用 issue 中显示的 rsc:// 路径,通过 board.fs.info、duckdb.register_filesystem(board.fs) 和 read_parquet 重现该故障。将正常工作的 S3 示例与 Posit Connect 路径进行比较,并检查 parquet 文件信息是如何返回的;完成标准是 DuckDB 可以直接查询 parquet pin,且不会出现 missing-magic-bytes 错误。
由索引模型根据 Issue 内容生成。
描述
Since pins-python uses fsspec under the hood, users are able to query pins data directly using duckdb's fsspec integration.
While https://github.com/rstudio/pins-python/pull/193 allows duckdb to query CSV pins on posit connect, parquet files cannot be queried. This is likely because duckdb needs to scan parquet headers.
Below, I provide examples, but first--here is a snippet to enable logging to stdout:
import logging
import sys
root = logging.getLogger("pins")
root.setLevel(logging.DEBUG)
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
handler.setFormatter(formatter)
root.addHandler(handler)
Querying parquet pins on s3 (for reference)
First, here is how you connect to a temporary s3 board, and return info on a file:
# create a temporary board, with the contents of the pins-compat test board ----
# note that my s3 credentials are in a .env file, see .env.dev
from dotenv import load_dotenv
load_dotenv()
bb = BoardBuilder("s3")
board = bb.create_tmp_board("pins/tests/pins-compat")
# display info for a csv file ----
board.fs.info(f"s3://{board.board}/df_csv/20220214T163718Z-eceac/df_csv.csv")
{'ETag': '"e6e2bc89538baa1ee31e3294efcb1d82"',
'LastModified': datetime.datetime(2023, 4, 12, 15, 22, 41, tzinfo=tzutc()),
'size': 20,
'name': 'ci-pins/222afb60-8e19-4cc0-b1a5-80098d0f410d/df_csv/20220214T163718Z-eceac/df_csv.csv',
'type': 'file',
'StorageClass': 'STANDARD',
'VersionId': None,
'ContentType': 'text/csv'}
Next, we'll add a parquet pin
from pins.data import mtcars
board.pin_write(mtcars, "df_parquet", type="parquet")
board.pin_versions("df_parquet")
created hash version
0 2023-04-12 11:30:57 69d97 20230412T113057Z-69d97
Finally, we'll query directly in duckdb
import duckdb
duckdb.register_filesystem(board.fs)
# query via duckdb! ----
data_path = f"s3://{board.board}/df_parquet/20230412T113057Z-69d97/df_parquet.parquet"
duckdb.execute(f"SELECT mpg FROM read_parquet('{data_path}')").df()
Querying parquet in pins
import pins
import duckdb
# note that my connect credentials are in a .env file
from dotenv import load_dotenv
load_dotenv()
# connect to board, register fs to duckdb ----
board = pins.board_connect("https://colorado.posit.co/rsc")
duckdb.register_filesystem(board.fs)
# look up bundle id ----
board.pin_meta("michael.chow/mtcars3")
# query with duckdb ----
duckdb.execute(
"SELECT * FROM read_parquet('rsc://michael.chow/mtcars3/72103/mtcars3.parquet')"
).df()
InvalidInputException: Invalid Input Error: No magic bytes found at end of file 'rsc://michael.chow/mtcars3/72103/mtcars3.parquet'
I think the issue has to do with how we're returning info on the file.
- 主要语言
- Python
- 星标
- 59
- 派生
- 11
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rstudio/pins-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
rstudio/pins-python#367 ·
-
.maint
难度 2/5 1-3 小时 新手友好度 62/100
rstudio/pins-python#280 ·
-
testing
难度 2/5 1-3 小时 新手友好度 62/100
rstudio/pins-python#196 ·
-
.enhancement
难度 5/5 一周以上 新手友好度 35/100
rstudio/pins-python#363 ·
-
难度 2/5 1-3 小时 新手友好度 55/100
rstudio/pins-python#354 ·
查看 rstudio/pins-python 的全部 Issue
相似的 Issue
-
docs(contributing): the two things that silently block a PR可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭available documentation good first issue
难度 1/5 1-3 小时 新手友好度 95/100
Nixitov/Riptide-Native#944 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
JTHCode/secretguard#24 ·
维护者通常 1 天内回复
-
area: middleware documentation good first issue
难度 2/5 1-3 小时 新手友好度 88/100
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
good first issue
难度 1/5 1 小时以内 新手友好度 95/100
omarelshamy25x/shamy-hijri#63 ·
维护者通常 1 天内回复