
- Apache Drill Tutorial
- Apache Drill - Home
- Apache Drill - Introduction
- Apache Drill - Fundamentals
- Apache Drill - Architecture
- Apache Drill - Installation
- Apache Drill - SQL Operations
- Apache Drill - Query using JSON
- Window Functions using JSON
- Querying Complex Data
- Data Definition Statements
- Apache Drill - Querying Data
- Querying Data using HBase
- Querying Data using Hive
- Apache Drill - Querying Parquet Files
- Apache Drill - JDBC Interface
- Apache Drill - Custom Function
- Apache Drill - Contributors
- Apache Drill Useful Resources
- Apache Drill - Quick Guide
- Apache Drill - Useful Resources
- Apache Drill - Discussion
Apache Drill - FLATTEN Function
FLATTEN separates the elements in a repeated field into individual records.
Syntax
FLATTEN(x)
Where,
x - JSON array.
Create a JSON file named “array.json” as shown in the following program.
{ "num1" : 10, "num2" : [10,20,30], "num3" : " simple json array", "num4" : 50.5 }
Now we can execute this query in Drill.
The following program shows the query for this function −
Query
0: jdbc:drill:zk = local> select *,flatten(num2) as flatten from dfs.`/Users/../workspace/Drill-samples/array.json`;
Result
num1 num2 num3 num4 flatten 10 [10,20,30] simple json array 50.5 10 10 [10,20,30] simple json array 50.5 20 10 [10,20,30] simple json array 50.5 30
apache_drill_querying_complex_data.htm
Advertisements