nealrichardson commented on code in PR #12826:
URL: https://github.com/apache/arrow/pull/12826#discussion_r923415768
##########
r/tests/testthat/test-dataset.R:
##########
@@ -1226,3 +1225,21 @@ test_that("FileSystemFactoryOptions input validation", {
fixed = TRUE
)
})
+
+test_that("can add in augmented fields", {
Review Comment:
What happens if you have a Table as your data source and you do
`add_filename()`?
##########
r/R/dataset.R:
##########
@@ -438,3 +438,20 @@ stop_if_no_datasets <- function() {
stop("This build of the arrow package does not support Datasets", call. =
FALSE)
}
}
+
+#' Add filename as dataset column
+#'
Review Comment:
This probably should have more documentation, noting what it returns, what
it does, how it (presumably) only does anything if you're doing a query on a
Dataset, etc.
##########
r/R/dataset.R:
##########
@@ -438,3 +438,20 @@ stop_if_no_datasets <- function() {
stop("This build of the arrow package does not support Datasets", call. =
FALSE)
}
}
+
+#' Add filename as dataset column
+#'
+#' @examplesIf requireNamespace("dplyr", quietly = TRUE)
+#' library(dplyr)
+#' tf <- tempfile()
+#' dir.create(tf)
+#' write_dataset(mtcars, tf, partitioning = "cyl")
+#'
+#' open_dataset(tf) %>%
+#' mutate(filename = add_filename()) %>%
+#' collect()
+#'
+#' @export
+add_filename <- function() {
Review Comment:
Should this just go in nse_funcs? Or does it have value outside of it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]