Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/15608#discussion_r84815775
--- Diff: R/pkg/R/utils.R ---
@@ -339,20 +339,40 @@ varargsToEnv <- function(...) {
varargsToStrEnv <- function(...) {
pairs <- list(...)
env <- new.env()
- for (name in names(pairs)) {
- value <- pairs[[name]]
- if (!(is.logical(value) || is.numeric(value) || is.character(value) ||
is.null(value))) {
- stop(paste0("Unsupported type for ", name, " : ", class(value),
- ". Supported types are logical, numeric, character and NULL."))
- }
- if (is.logical(value)) {
- env[[name]] <- tolower(as.character(value))
- } else if (is.null(value)) {
- env[[name]] <- value
- } else {
- env[[name]] <- as.character(value)
+ nameList <- names(pairs)
+ ignoredNames <- list()
+ i <- 1
--- End diff --
Oh, sure. Actually, it took me a while to find out a clean way but it ended
up with introducing another variable here...
```r
value <- pairs[[name]]
```
is failed when `name` is empty string (when they are non-named arguments),
producing the error as below:
```r
Error in env[[name]] <- value :
zero-length variable name
```
I wanted to access to that problematic values to print in
```r
ignoredNames <- append(ignoredNames, pairs[i])
...
warning(paste0("Non-named arguments ignored: ", paste(ignoredNames,
collapse = ", "), "."),
call. = FALSE)
```
To cut it short, I introduced that variable to access to the value when
`name` is empty. Maybe there should be another cleaver way but I couldn't come
up with it.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]