arrow
包包含 37 个 dplyr
表函数的方法,其中许多是用于对一个或多个表进行转换的“动词”。该包还将 212 个 R 函数映射到 Arrow 计算库中的相应函数。这允许您在 dplyr
方法内部编写调用 R 函数的代码,包括 stringr
和 lubridate
等包中的许多函数,它们将被转换为 Arrow 并在 Arrow 查询引擎 (Acero) 上运行。本文档列出了所有映射的函数。
dplyr
动词
大多数动词函数返回一个 arrow_dplyr_query
对象,其精神与 dbplyr::tbl_lazy
相似。这意味着这些动词不会立即对数据进行查询评估。要运行查询,请调用 compute()
,它返回一个 arrow
表,或调用 collect()
,它将结果表拉入 R tibble
。
anti_join()
:忽略copy
参数distinct()
:不支持.keep_all = TRUE
full_join()
:忽略copy
参数inner_join()
:忽略copy
参数left_join()
:忽略copy
参数pull()
:不支持name
参数;默认返回一个 R 向量,但此行为已弃用,将在未来的版本中返回一个 Arrow ChunkedArray。 提供as_vector = TRUE/FALSE
来控制此行为,或全局设置options(arrow.pull_as_vector)
。right_join()
:忽略copy
参数semi_join()
:忽略copy
参数slice_head()
:不支持组内切片; Arrow 数据集没有行顺序,因此 head 是不确定的; 仅在无需计算即可知道nrow()
的查询上支持prop
slice_max()
:不支持组内切片;不支持with_ties = TRUE
(dplyr 默认值); 仅在无需计算即可知道nrow()
的查询上支持prop
slice_min()
:不支持组内切片;不支持with_ties = TRUE
(dplyr 默认值); 仅在无需计算即可知道nrow()
的查询上支持prop
slice_sample()
:不支持组内切片;不支持replace = TRUE
和weight_by
参数;仅在无需计算即可知道nrow()
的查询上支持n
slice_tail()
:不支持组内切片;Arrow 数据集没有行顺序,因此 tail 是不确定的;仅在无需计算即可知道nrow()
的查询上支持prop
summarise()
:当前不支持窗口函数;不支持参数.drop = FALSE
和.groups = "rowwise"
函数映射
在下面的列表中,列出了 Acero 和 R 函数之间行为或支持的任何差异。如果没有注释跟随函数名称,则可以假定该函数在 Acero 中的工作方式与在 R 中的工作方式相同。
可以将函数称为 pkg::fun()
或 fun()
,即 str_sub()
和 stringr::str_sub()
都可以工作。
除了这些函数之外,您还可以直接调用 Arrow 的 262 个计算函数。Arrow 有许多函数没有映射到现有的 R 函数。在其他情况下,即使存在 R 函数映射,如果您不希望 R 映射进行使 Acero 表现得像 R 的调整,您仍然可以直接调用 Arrow 函数。这些函数列在 C++ 文档 中,并且在 R 的函数注册表中,它们的名称带有 arrow_
前缀,例如 arrow_ascii_is_decimal
。
base
as.Date()
:Arrow 中不支持多个tryFormats
。考虑使用 lubridate 专用解析函数ymd()
、ymd()
等。as.difftime()
:仅支持units = "secs"
(默认值)data.frame()
:不支持row.names
和check.rows
参数;stringsAsFactors
必须为FALSE
difftime()
:仅支持units = "secs"
(默认值); 不支持tz
参数nchar()
:不支持allowNA = TRUE
和keepNA = TRUE
paste()
:尚不支持collapse
参数paste0()
:尚不支持collapse
参数strptime()
:接受base
函数中不存在的unit
参数。有效值为“s”、“ms”(默认值)、“us”、“ns”。substr()
:start
和stop
的长度必须为 1
dplyr
case_when()
:不支持.ptype
和.size
参数
lubridate
dmy()
:不支持locale
参数dmy_h()
:不支持locale
参数dmy_hm()
:不支持locale
参数dmy_hms()
:不支持locale
参数dpicoseconds()
:不支持dym()
:不支持locale
参数fast_strptime()
:不支持lt
和cutoff_2000
的非默认值force_tz()
:不支持从非 UTC 时区进行时区转换;对于不存在的时间,支持roll_dst
值“error”和“boundary”,对于不明确的时间,支持roll_dst
值“error”、“pre”和“post”。is.Date()
is.POSIXct()
make_datetime()
:仅支持 UTC(默认)时区make_difftime()
:仅支持units = "secs"
(默认值);不支持同时提供num
和...
mdy()
:不支持locale
参数mdy_h()
:不支持locale
参数mdy_hm()
:不支持locale
参数mdy_hms()
:不支持locale
参数my()
:不支持locale
参数myd()
:不支持locale
参数parse_date_time()
:不支持quiet = FALSE
。可用的格式有 H, I, j, M, S, U, w, W, y, Y, R, T。在 Linux 和 OS X 上,还支持 a, A, b, B, Om, p, r。ydm()
:不支持locale
参数ydm_h()
:不支持locale
参数ydm_hm()
:不支持locale
参数ydm_hms()
:不支持locale
参数ym()
:不支持locale
参数ymd()
:不支持locale
参数ymd_h()
:不支持locale
参数ymd_hm()
:不支持locale
参数ymd_hms()
:不支持locale
参数yq()
:不支持locale
参数
stats
median()
:计算近似中位数 (t-digest)quantile()
:probs
的长度必须为 1;计算近似分位数 (t-digest)
stringr
任何函数均不支持模式修饰符 coll()
和 boundary()
。
str_c()
:尚不支持collapse
参数str_count()
:pattern
必须是长度为 1 的字符向量str_split()
:不支持不区分大小写的字符串拆分和拆分为 0 个部分str_sub()
:start
和end
的长度必须为 1