-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-19828][R] Support array type in from_json in R #17178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
10feb9d
f13ad18
5c2450d
d01f952
8ec7cd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2437,6 +2437,7 @@ setMethod("date_format", signature(y = "Column", x = "character"), | |||||||||||||||||
| #' | ||||||||||||||||||
| #' @param x Column containing the JSON string. | ||||||||||||||||||
| #' @param schema a structType object to use as the schema to use when parsing the JSON string. | ||||||||||||||||||
| #' @param asJsonArray indicating if input string is JSON array or object. | ||||||||||||||||||
| #' @param ... additional named properties to control how the json is parsed, accepts the same | ||||||||||||||||||
| #' options as the JSON data source. | ||||||||||||||||||
| #' | ||||||||||||||||||
|
|
@@ -2452,11 +2453,18 @@ setMethod("date_format", signature(y = "Column", x = "character"), | |||||||||||||||||
| #'} | ||||||||||||||||||
| #' @note from_json since 2.2.0 | ||||||||||||||||||
| setMethod("from_json", signature(x = "Column", schema = "structType"), | ||||||||||||||||||
| function(x, schema, ...) { | ||||||||||||||||||
| function(x, schema, asJsonArray = FALSE, ...) { | ||||||||||||||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @felixcheung, I am still not fully sure of this name, |
||||||||||||||||||
| if (asJsonArray) { | ||||||||||||||||||
| jschema <- callJStatic("org.apache.spark.sql.types.DataTypes", | ||||||||||||||||||
| "createArrayType", | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need a wrapper, actually? can't we call
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, sure. Let me try.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems we'd better use
per spark/sql/catalyst/src/main/scala/org/apache/spark/sql/types/ArrayType.scala Lines 49 to 56 in 04ee8cf
Let me remove that new wrapper and use the original one. |
||||||||||||||||||
| schema$jobj) | ||||||||||||||||||
| } else { | ||||||||||||||||||
| jschema <- schema$jobj | ||||||||||||||||||
| } | ||||||||||||||||||
| options <- varargsToStrEnv(...) | ||||||||||||||||||
| jc <- callJStatic("org.apache.spark.sql.functions", | ||||||||||||||||||
| "from_json", | ||||||||||||||||||
| x@jc, schema$jobj, options) | ||||||||||||||||||
| x@jc, jschema, options) | ||||||||||||||||||
| column(jc) | ||||||||||||||||||
| }) | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe clarifying
JSON array or object.->JSON array of objects or a single object.