Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-7861

Add Function to Obtain Inner Map Schemata

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.18.0
    • 1.19.0
    • Metadata
    • None

    Description

      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.

          1. 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`.

      Attachments

        Activity

          People

            cgivre Charles Givre
            cgivre Charles Givre
            Cong Luo Cong Luo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: