Github user shivaram commented on a diff in the pull request:
https://github.com/apache/spark/pull/9769#discussion_r46087941
--- Diff: R/pkg/R/DataFrame.R ---
@@ -700,25 +700,28 @@ setMethod("collect",
# data of complex type can be held. But getting a cell
from a column
# of list type returns a list instead of a vector. So for
columns of
# non-complex type, append them as vector.
+ #
+ # For columns of complex type, be careful to access them.
+ # Get a column of complex type returns a list.
+ # Get a cell from a column of complex type returns a list
instead of a vector.
col <- listCols[[colIndex]]
+ colName <- dtypes[[colIndex]][[1]]
if (length(col) <= 0) {
- df[[names[colIndex]]] <- col
+ df[[colName]] <- col
} else {
- # TODO: more robust check on column of primitive types
- vec <- do.call(c, col)
- if (class(vec) != "list") {
- df[[names[colIndex]]] <- vec
+ colType <- dtypes[[colIndex]][[2]]
+ if (!is.null(PRIMITIVE_TYPES[[colType]]) && colType !=
"binary") {
--- End diff --
Could you add a comment here as well ? Something like `NOTE: "binary"
columns behave like complex types`
---
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]