Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/18498#discussion_r126296188
--- Diff: R/pkg/R/functions.R ---
@@ -2163,10 +2164,15 @@ setMethod("date_format", signature(y = "Column", x
= "character"),
#' df2 <- sql("SELECT named_struct('name', 'Bob') as people")
#' df2 <- mutate(df2, people_json = to_json(df2$people))
#' schema <- structType(structField("name", "string"))
-#' head(select(df2, from_json(df2$people_json, schema)))}
+#' head(select(df2, from_json(df2$people_json, schema)))
+#' head(select(df2, from_json(df2$people_json, "name STRING")))}
#' @note from_json since 2.2.0
-setMethod("from_json", signature(x = "Column", schema = "structType"),
+setMethod("from_json", signature(x = "Column", schema =
"characterOrstructType"),
function(x, schema, as.json.array = FALSE, ...) {
+ if (is.character(schema)) {
+ schema <- structTypeFromDDL(schema)
+ }
--- End diff --
Otherwise, could we leave this out here for now if you don't strongly feel
about this currently?
I was thinking a JSON string support exists for backward compatibility in
favour of DDL support and the usecase would be quite rare but indeed it is
inconsistent with Python/Scala.
---
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]