Skip to content

Commit 17d8190

Browse files
committed
Rename asJsonArray to as.json.array in from_json function in R
1 parent 86d251c commit 17d8190

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

R/pkg/R/functions.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,12 +2438,12 @@ setMethod("date_format", signature(y = "Column", x = "character"),
24382438
#' from_json
24392439
#'
24402440
#' Parses a column containing a JSON string into a Column of \code{structType} with the specified
2441-
#' \code{schema} or array of \code{structType} if \code{asJsonArray} is set to \code{TRUE}.
2441+
#' \code{schema} or array of \code{structType} if \code{as.json.array} is set to \code{TRUE}.
24422442
#' If the string is unparseable, the Column will contains the value NA.
24432443
#'
24442444
#' @param x Column containing the JSON string.
24452445
#' @param schema a structType object to use as the schema to use when parsing the JSON string.
2446-
#' @param asJsonArray indicating if input string is JSON array of objects or a single object.
2446+
#' @param as.json.array indicating if input string is JSON array of objects or a single object.
24472447
#' @param ... additional named properties to control how the json is parsed, accepts the same
24482448
#' options as the JSON data source.
24492449
#'
@@ -2459,8 +2459,8 @@ setMethod("date_format", signature(y = "Column", x = "character"),
24592459
#'}
24602460
#' @note from_json since 2.2.0
24612461
setMethod("from_json", signature(x = "Column", schema = "structType"),
2462-
function(x, schema, asJsonArray = FALSE, ...) {
2463-
if (asJsonArray) {
2462+
function(x, schema, as.json.array = FALSE, ...) {
2463+
if (as.json.array) {
24642464
jschema <- callJStatic("org.apache.spark.sql.types.DataTypes",
24652465
"createArrayType",
24662466
schema$jobj)

R/pkg/inst/tests/testthat/test_sparkSQL.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ test_that("column functions", {
14541454
jsonArr <- "[{\"name\":\"Bob\"}, {\"name\":\"Alice\"}]"
14551455
df <- as.DataFrame(list(list("people" = jsonArr)))
14561456
schema <- structType(structField("name", "string"))
1457-
arr <- collect(select(df, alias(from_json(df$people, schema, asJsonArray = TRUE), "arrcol")))
1457+
arr <- collect(select(df, alias(from_json(df$people, schema, as.json.array = TRUE), "arrcol")))
14581458
expect_equal(ncol(arr), 1)
14591459
expect_equal(nrow(arr), 1)
14601460
expect_is(arr[[1]][[1]], "list")

0 commit comments

Comments
 (0)