[ 
https://issues.apache.org/jira/browse/DRILL-7861?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Cong Luo resolved DRILL-7861.
-----------------------------
      Reviewer: Cong Luo
    Resolution: Fixed

> Add Function to Obtain Inner Map Schemata
> -----------------------------------------
>
>                 Key: DRILL-7861
>                 URL: https://issues.apache.org/jira/browse/DRILL-7861
>             Project: Apache Drill
>          Issue Type: Improvement
>          Components: Metadata
>    Affects Versions: 1.18.0
>            Reporter: Charles Givre
>            Assignee: Charles Givre
>            Priority: Major
>             Fix For: 1.19.0
>
>
> This function allows you to drill down into the schema of maps.  The REST API 
> and JDBC interfaces will only return `MAP`, `LIST` for the MAP, however, it 
> is not possible to get 
> the schema of the inner map. The function `getMapSchema(<MAP>)` will return a 
> `MAP` of the fields and datatypes.
> ### Example Usage
> Using the data below, the query below will return the schema as shown below.
> ```bash
> apache drill> SELECT getMapSchema(record) AS schema FROM 
> dfs.test.`schema_test.json`;
> +----------------------------------------------------------------------------------+
> |                                      schema                                 
>      |
> +----------------------------------------------------------------------------------+
> | 
> {"int_field":"BIGINT","double_field":"FLOAT8","string_field":"VARCHAR","int_list":"REPEATED_BIGINT","double_list":"REPEATED_FLOAT8","map":"MAP"}
>  |
> +----------------------------------------------------------------------------------+
> 1 row selected (0.298 seconds)
> ```
> ```json
> {
>   "record" : {
>     "int_field": 1,
>     "double_field": 2.0,
>     "string_field": "My string",
>     "int_list": [1,2,3],
>     "double_list": [1.0,2.0,3.0],
>     "map": {
>       "nested_int_field" : 5,
>       "nested_double_field": 5.0,
>       "nested_string_field": "5.0"
>     }
>   },
>   "single_field": 10
> }
> ```
> The function returns an empty map if the row is `null`.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to