Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/18498#discussion_r126299087
--- 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 --
I see. So, you mean ...
`structTypeFromDDL` ->`structType.character` for `structType("a STRING, b
INT")` usage?
This makes much more sense to me and I'd like to propose `StructType(a
STRING, b INT")` case in Scala/Python side too.
For me, I would like to avoid JSON format if DDL format is allowed in any
event for now although we should keep our eyes on mailing list and JIRAs.
---
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]