GitHub user MaxGekk opened a pull request:

    https://github.com/apache/spark/pull/22226

    [SPARK-24391][SQL] Support arrays of any types by to_json

    ## What changes were proposed in this pull request?
    
    In the PR, I propose to extended `to_json` and support any types as element 
types of input arrays. It should allow converting arrays of primitive types and 
arrays of arrays. For example:
    
    ```
    select to_json(array('1','2','3'))
    > ["1","2","3"]
    select to_json(array(array(1,2,3),array(4)))
    > [[1,2,3],[4]]
    ``` 
    
    ## How was this patch tested?
    
    Added a couple sql tests for arrays of primitive type and of arrays. Also I 
added round trip test `from_json` -> `to_json`.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/MaxGekk/spark-1 to_json-array

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/22226.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #22226
    
----
commit fb727268b776f3c9b896abfee60e8538aa9e93e4
Author: Maxim Gekk <maxim.gekk@...>
Date:   2018-08-24T18:57:36Z

    Support arrays of any types in to_json

commit e9a5f50720d0e6ab301afaa3a4eff801de1240d7
Author: Maxim Gekk <maxim.gekk@...>
Date:   2018-08-24T19:18:19Z

    sql tests for array of primitive type and of arrays

----


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to