You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

R中调用arrow json reader触发NotImplemented错误求助

解决arrow包read_json_arrow读取远程URL的NotImplemented错误

错误原因

该错误源于read_json_arrow的底层C++实现尝试在非R线程中调用R的readBin()函数,而这种调用场景不被支持。直接传入远程URL时,arrow内部处理逻辑触发了这条不兼容的调用路径。

可行解决方案

方案1:先下载文件到本地再读取

先用R的文件下载工具将远程JSON保存到本地,再用read_json_arrow读取本地文件:

# 下载文件到临时路径
temp_file <- tempfile(fileext = ".json")
download.file("http://stats.oecd.org/sdmx-json/data/QNA/all/all?startTime=2009-Q1&endTime=2009-Q4", temp_file)

# 使用arrow读取本地文件
library(arrow)
read_json_arrow(temp_file)

方案2:用arrow的fs接口处理远程文件

利用fs::url()封装远程URL,让arrow通过自身文件系统逻辑读取,避免触发R线程调用:

library(arrow)
library(fs)

read_json_arrow(fs::url("http://stats.oecd.org/sdmx-json/data/QNA/all/all?startTime=2009-Q1&endTime=2009-Q4"))

方案3:先读取为原始字符再解析

通过readLines()获取JSON内容为字符向量,再传给read_json_arrow的text参数解析:

library(arrow)
# 读取远程内容为字符
json_text <- readLines("http://stats.oecd.org/sdmx-json/data/QNA/all/all?startTime=2009-Q1&endTime=2009-Q4", warn = FALSE)
# 合并为单字符串
json_text <- paste(json_text, collapse = "\n")
# 解析文本
read_json_arrow(text = json_text)

内容的提问来源于stack exchange,提问作者pluke

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 16:17:20