Apache Drill - KVGEN Function



This function returns a list of the keys that exist in the map.

Syntax

KVGEN(column name)

Create a simple JSON map file named “student_map” as shown in the following program.

{
   "student_ID" : {
      "001" : "Adam",
      "002" : "Amit"
   }
}

{
   "student_ID" : {
      "003" : "Bob",
      "004" : "David"
   }
}

The following program shows the query for this function −

Query

0: jdbc:drill:zk = local> select kvgen(student_ID) from
   dfs.`/Users/../workspace/Drill-samples/student_map.json`;

Result

EXPR$0
[{"key":"001","value":"Adam"},{"key":"002","value":"Amit"}]
[{“key":"003","value":"Bob"},{"key":"004","value":"David"}]
apache_drill_querying_complex_data.htm
Advertisements