Github user falaki commented on a diff in the pull request: https://github.com/apache/spark/pull/11336#discussion_r82887849 --- Diff: R/pkg/R/column.R --- @@ -32,35 +34,65 @@ setOldClass("jobj") #' @export #' @note Column since 1.4.0 setClass("Column", - slots = list(jc = "jobj")) + slots = list(jc = "jobj", df = "SparkDataFrameOrNull")) #' A set of operations working with SparkDataFrame columns #' @rdname columnfunctions #' @name columnfunctions NULL - -setMethod("initialize", "Column", function(.Object, jc) { +setMethod("initialize", "Column", function(.Object, jc, df) { .Object@jc <- jc + + # Some Column objects don't have any referencing DataFrame. In such case, df will be NULL. + if (missing(df)) { + df <- NULL + } + .Object@df <- df .Object }) +setMethod("show", signature = "Column", definition = function(object) { + MAX_ELEMENTS <- 20 + head.df <- head(object, MAX_ELEMENTS) + + if (length(head.df) == 0) { + colname <- callJMethod(object@jc, "toString") + cat(paste0(colname, "\n")) + cat(paste0("<Empty column>\n")) + } else { + show(head.df) + } + if (length(head.df) == MAX_ELEMENTS) { + cat(paste0("\b...\nDisplaying up to ", as.character(MAX_ELEMENTS), " elements only.")) + } +}) + +setMethod("collect", signature = "Column", definition = function(x) { --- End diff -- It seems Spark committers are still not sure about this feature. Maybe we can remove it for now and once the discussion is resolved we work on it as a separate PR?
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org