Skip to content
  • hyukjinkwon's avatar
    d1f6c64c
    [SPARK-19828][R] Support array type in from_json in R · d1f6c64c
    hyukjinkwon authored
    ## What changes were proposed in this pull request?
    
    Since we could not directly define the array type in R, this PR proposes to support array types in R as string types that are used in `structField` as below:
    
    ```R
    jsonArr <- "[{\"name\":\"Bob\"}, {\"name\":\"Alice\"}]"
    df <- as.DataFrame(list(list("people" = jsonArr)))
    collect(select(df, alias(from_json(df$people, "array<struct<name:string>>"), "arrcol")))
    ```
    
    prints
    
    ```R
          arrcol
    1 Bob, Alice
    ```
    
    ## How was this patch tested?
    
    Unit tests in `test_sparkSQL.R`.
    
    Author: hyukjinkwon <gurwls223@gmail.com>
    
    Closes #17178 from HyukjinKwon/SPARK-19828.
    d1f6c64c
    [SPARK-19828][R] Support array type in from_json in R
    hyukjinkwon authored
    ## What changes were proposed in this pull request?
    
    Since we could not directly define the array type in R, this PR proposes to support array types in R as string types that are used in `structField` as below:
    
    ```R
    jsonArr <- "[{\"name\":\"Bob\"}, {\"name\":\"Alice\"}]"
    df <- as.DataFrame(list(list("people" = jsonArr)))
    collect(select(df, alias(from_json(df$people, "array<struct<name:string>>"), "arrcol")))
    ```
    
    prints
    
    ```R
          arrcol
    1 Bob, Alice
    ```
    
    ## How was this patch tested?
    
    Unit tests in `test_sparkSQL.R`.
    
    Author: hyukjinkwon <gurwls223@gmail.com>
    
    Closes #17178 from HyukjinKwon/SPARK-19828.
Loading