cgivre opened a new pull request #2171: URL: https://github.com/apache/drill/pull/2171
# [DRILL-7861](https://issues.apache.org/jira/browse/DRILL-7861): Add Function to Obtain Inner Map Schemata ## Description (Please describe the change. If more than one ticket is fixed, include a reference to those tickets.) ## Documentation 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`. ## Testing Added three unit tests. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
