Github user felixcheung commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11336#discussion_r83154700
  
    --- Diff: R/pkg/R/column.R ---
    @@ -29,38 +31,61 @@ setOldClass("jobj")
     #' @rdname column
     #'
     #' @slot jc reference to JVM SparkDataFrame column
    +#' @slot df the parent SparkDataFrame of the Column object
     #' @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", 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("head", signature = "Column", definition = function(x, n=6) {
    --- End diff --
    
    ditto here, `#' @rdname head`


---
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

Reply via email to