Github user felixcheung commented on a diff in the pull request:
https://github.com/apache/spark/pull/16510#discussion_r95515567
--- Diff: R/pkg/R/DataFrame.R ---
@@ -1727,14 +1727,21 @@ setMethod("$", signature(x = "SparkDataFrame"),
getColumn(x, name)
})
-#' @param value a Column or \code{NULL}. If \code{NULL}, the specified
Column is dropped.
+#' @param value a Column or an atomic vector in the length of 1 as literal
value, or \code{NULL}.
+#' If \code{NULL}, the specified Column is dropped.
#' @rdname select
#' @name $<-
#' @aliases $<-,SparkDataFrame-method
#' @note $<- since 1.4.0
setMethod("$<-", signature(x = "SparkDataFrame"),
function(x, name, value) {
- stopifnot(class(value) == "Column" || is.null(value))
+ if (class(value) != "Column" && !is.null(value)) {
+ if (isAtomicLengthOne(value)) {
+ value <- lit(value)
+ } else {
+ stop("value must be a Column, Literal value as atomic in
length of 1, or NULL")
--- End diff --
I was thinking org.apache.spark.sql.catalyst.expressions.Literal as the
type, but I guess i can use the lower case term too
---
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]