Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/18498#discussion_r126299217
--- 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 --
but should we maybe keep `structTypeFromDDL` here for now? I am just a bit
worried that there are variants in R API alone.
I can ask this suggestion, `StructType("a STRING, b INT")`/`structType("a
STRING, b INT")`, to the mailing list in coming few days if you feel okay with
it.
---
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]