http://git-wip-us.apache.org/repos/asf/drill-site/blob/d42f2cdd/docs/lession-3-run-queries-on-complex-data-types/index.html
----------------------------------------------------------------------
diff --git a/docs/lession-3-run-queries-on-complex-data-types/index.html
b/docs/lession-3-run-queries-on-complex-data-types/index.html
deleted file mode 100644
index b3ccf1d..0000000
--- a/docs/lession-3-run-queries-on-complex-data-types/index.html
+++ /dev/null
@@ -1,1211 +0,0 @@
-<!DOCTYPE html>
-<html>
-
-<head>
-
-<meta charset="UTF-8">
-<meta name=viewport content="width=device-width, initial-scale=1">
-
-
-<title>Lession 3: Run Queries on Complex Data Types - Apache Drill</title>
-
-<link href="/css/syntax.css" rel="stylesheet" type="text/css">
-<link href="/css/style.css" rel="stylesheet" type="text/css">
-<link href="/css/arrows.css" rel="stylesheet" type="text/css">
-<link href="/css/breadcrumbs.css" rel="stylesheet" type="text/css">
-<link href="/css/code.css" rel="stylesheet" type="text/css">
-<link rel="stylesheet"
href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
-<link href="/css/responsive.css" rel="stylesheet" type="text/css">
-
-<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
-<link rel="icon" href="/favicon.ico" type="image/x-icon">
-
-<script language="javascript" type="text/javascript"
src="/js/lib/jquery-1.11.1.min.js"></script>
-<script language="javascript" type="text/javascript"
src="/js/lib/jquery.easing.1.3.js"></script>
-<script language="javascript" type="text/javascript"
src="/js/modernizr.custom.js"></script>
-<script language="javascript" type="text/javascript"
src="/js/script.js"></script>
-<script language="javascript" type="text/javascript"
src="/js/drill.js"></script>
-
-
-</head>
-
-<body onResize="resized();">
- <div class="page-wrap">
- <div class="bui"></div>
-
-<div id="menu" class="mw">
-<ul>
- <li class='toc-categories'>
- <a class="expand-toc-icon" href="javascript:void(0);"><i class="fa
fa-bars"></i></a>
- </li>
- <li class="logo"><a href="/"></a></li>
- <li class='expand-menu'>
- <a href="javascript:void(0);"><span class='menu-text'>Menu</span><span
class='expand-icon'><i class="fa fa-bars"></i></span></a>
- </li>
- <li class='clear-float'></li>
- <li class="documentation-menu">
- <a href="/docs/">Documentation</a>
- <ul>
-
- <li><a href="/docs/getting-started/">Getting Started</a></li>
-
- <li><a href="/docs/architecture/">Architecture</a></li>
-
- <li><a href="/docs/tutorials/">Tutorials</a></li>
-
- <li><a href="/docs/install-drill/">Install Drill</a></li>
-
- <li><a href="/docs/configure-drill/">Configure Drill</a></li>
-
- <li><a href="/docs/connect-a-data-source/">Connect a Data
Source</a></li>
-
- <li><a href="/docs/odbc-jdbc-interfaces/">ODBC/JDBC Interfaces</a></li>
-
- <li><a href="/docs/query-data/">Query Data</a></li>
-
- <li><a href="/docs/sql-reference/">SQL Reference</a></li>
-
- <li><a href="/docs/data-sources-and-file-formats/">Data Sources and
File Formats</a></li>
-
- <li><a href="/docs/develop-custom-functions/">Develop Custom
Functions</a></li>
-
- <li><a href="/docs/developer-information/">Developer
Information</a></li>
-
- <li><a href="/docs/release-notes/">Release Notes</a></li>
-
- <li><a href="/docs/sample-datasets/">Sample Datasets</a></li>
-
- <li><a href="/docs/archived-pages/">Archived Pages</a></li>
-
- <li><a href="/docs/progress-reports/">Progress Reports</a></li>
-
- <li><a href="/docs/project-bylaws/">Project Bylaws</a></li>
-
- </ul>
- </li>
- <li class='nav'>
- <a href="/community-resources/">Community</a>
- <ul>
- <li><a href="/team/">Team</a></li>
- <li><a href="/mailinglists/">Mailing Lists</a></li>
- <li><a href="/community-resources/">Community Resources</a></li>
- </ul>
- </li>
- <li class='nav'><a href="/faq/">FAQ</a></li>
- <li class='nav'><a href="/blog/">Blog</a></li>
- <li id="twitter-menu-item"><a href="https://twitter.com/apachedrill"
title="apachedrill on twitter" target="_blank"><img
src="/images/twitter_32_26_white.png" alt="twitter logo" align="center"></a>
</li>
- <li class='search-bar'>
- <form id="drill-search-form">
- <input type="text" placeholder="Search Apache Drill"
id="drill-search-term" />
- <button type="submit">
- <i class="fa fa-search"></i>
- </button>
- </form>
- </li>
- <li class="d">
- <a href="/download/">
- <i class="fa fa-cloud-download"></i> Download
- </a>
- </li>
-</ul>
-</div>
-
-
-
-
-
-
-
-<aside class="sidebar">
- <div class="docsidebar">
- <div class="docsidebarwrapper">
- <ul style="display: block;">
-
-
- <li class="toctree-l1"><a href="javascript: void(0);">Getting
Started</a></li>
- <ul style="display: none">
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/drill-introduction/">Drill Introduction</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/why-drill/">Why Drill</a></li>
-
-
- </ul>
-
-
-
- <li class="toctree-l1"><a href="javascript:
void(0);">Architecture</a></li>
- <ul style="display: none">
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/architecture-introduction/">Architecture Introduction</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/core-modules/">Core Modules</a></li>
-
-
-
- <li class="toctree-l2"><a href="javascript:
void(0);">Architectural Highlights</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/flexibility/">Flexibility</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/performance/">Performance</a></li>
-
- </ul>
-
-
- </ul>
-
-
-
- <li class="toctree-l1 current_section "><a href="javascript:
void(0);">Tutorials</a></li>
- <ul class="current_section">
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/tutorials-introduction/">Tutorials Introduction</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/drill-in-10-minutes/">Drill in 10 Minutes</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/analyzing-the-yelp-academic-dataset/">Analyzing the Yelp Academic
Dataset</a></li>
-
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">Learn
Drill with the MapR Sandbox</a></li>
- <ul style="">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/about-the-mapr-sandbox/">About the MapR Sandbox</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/installing-the-apache-drill-sandbox/">Installing the Apache Drill
Sandbox</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/getting-to-know-the-drill-sandbox/">Getting to Know the Drill
Sandbox</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/lession-1-learn-about-the-data-set/">Lession 1: Learn about the
Data Set</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/lession-2-run-queries-with-ansi-sql/">Lession 2: Run Queries with
ANSI SQL</a></li>
-
- <li class="toctree-l3 current"><a class="reference internal"
href="/docs/lession-3-run-queries-on-complex-data-types/">Lession 3: Run
Queries on Complex Data Types</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/summary/">Summary</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/analyzing-highly-dynamic-datasets/">Analyzing Highly Dynamic
Datasets</a></li>
-
-
- </ul>
-
-
-
- <li class="toctree-l1"><a href="javascript: void(0);">Install
Drill</a></li>
- <ul style="display: none">
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/install-drill-introduction/">Install Drill Introduction</a></li>
-
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">Installing
Drill in Embedded Mode</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/embedded-mode-prerequisites/">Embedded Mode Prerequisites</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/installing-drill-on-linux-and-mac-os-x/">Installing Drill on Linux
and Mac OS X</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/starting-drill-on-linux-and-mac-os-x/">Starting Drill on Linux and
Mac OS X</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/installing-drill-on-windows/">Installing Drill on Windows</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/starting-drill-on-windows/">Starting Drill on Windows</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">Installing
Drill in Distributed Mode</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/distributed-mode-prerequisites/">Distributed Mode
Prerequisites</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/installing-drill-on-the-cluster/">Installing Drill on the
Cluster</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/starting-drill-in-distributed-mode/">Starting Drill in Distributed
Mode</a></li>
-
- </ul>
-
-
- </ul>
-
-
-
- <li class="toctree-l1"><a href="javascript: void(0);">Configure
Drill</a></li>
- <ul style="display: none">
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/configure-drill-introduction/">Configure Drill Introduction</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/configuring-drill-memory/">Configuring Drill Memory</a></li>
-
-
-
- <li class="toctree-l2"><a href="javascript:
void(0);">Configuring a Multitenant Cluster</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/configuring-a-multitenant-cluster-introduction/">Configuring a
Multitenant Cluster Introduction</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/configuring-multitenant-resources/">Configuring Multitenant
Resources</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/configuring-resources-for-a-shared-drillbit/">Configuring Resources
for a Shared Drillbit</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/configuring-user-impersonation/">Configuring User
Impersonation</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/configuring-user-authentication/">Configuring User
Authentication</a></li>
-
-
-
- <li class="toctree-l2"><a href="javascript:
void(0);">Configuration Options</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/configuration-options-introduction/">Configuration Options
Introduction</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/start-up-options/">Start-Up Options</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/planning-and-execution-options/">Planning and Execution
Options</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/persistent-configuration-storage/">Persistent Configuration
Storage</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/ports-used-by-drill/">Ports Used by Drill</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/partition-pruning/">Partition Pruning</a></li>
-
-
- </ul>
-
-
-
- <li class="toctree-l1"><a href="javascript: void(0);">Connect a Data
Source</a></li>
- <ul style="display: none">
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/connect-a-data-source-introduction/">Connect a Data Source
Introduction</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/storage-plugin-registration/">Storage Plugin Registration</a></li>
-
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">Storage
Plugin Configuration</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/plugin-configuration-introduction/">Plugin Configuration
Introduction</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/workspaces/">Workspaces</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/file-system-storage-plugin/">File System Storage Plugin</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/hbase-storage-plugin/">HBase Storage Plugin</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/hive-storage-plugin/">Hive Storage Plugin</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/drill-default-input-format/">Drill Default Input Format</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/mongodb-plugin-for-apache-drill/">MongoDB Plugin for Apache
Drill</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/mapr-db-format/">MapR-DB Format</a></li>
-
-
- </ul>
-
-
-
- <li class="toctree-l1"><a href="javascript: void(0);">ODBC/JDBC
Interfaces</a></li>
- <ul style="display: none">
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/interfaces-introduction/">Interfaces Introduction</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/using-jdbc/">Using JDBC</a></li>
-
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">Using ODBC
on Linux and Mac OS X</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/odbc-on-linux-and-mac-introduction/">ODBC on Linux and Mac
Introduction</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/installing-the-driver-on-linux/">Installing the Driver on
Linux</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/installing-the-driver-on-mac-os-x/">Installing the Driver on Mac OS
X</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/configuring-connections-on-linux-and-mac-os-x/">Configuring
Connections on Linux and Mac OS X</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/driver-configuration-options/">Driver Configuration Options</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/using-a-connection-string/">Using a Connection String</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/advanced-properties/">Advanced Properties</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/testing-the-odbc-connection/">Testing the ODBC Connection</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">Using ODBC
on Windows</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/installing-the-driver-on-windows/">Installing the Driver on
Windows</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/configuring-connections-on-windows/">Configuring Connections on
Windows</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/connecting-to-odbc-data-sources/">Connecting to ODBC Data
Sources</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/tableau-examples/">Tableau Examples</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/using-drill-explorer-on-windows/">Using Drill Explorer on
Windows</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/using-microstrategy-analytics-with-drill/">Using MicroStrategy
Analytics with Drill</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/using-apache-drill-with-tibco-spotfire-desktop/">Using Apache Drill
with Tibco Spotfire Desktop</a></li>
-
-
- </ul>
-
-
-
- <li class="toctree-l1"><a href="javascript: void(0);">Query
Data</a></li>
- <ul style="display: none">
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/query-data-introduction/">Query Data Introduction</a></li>
-
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">Querying a
File System</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/querying-a-file-system-introduction/">Querying a File System
Introduction</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/querying-json-files/">Querying JSON Files</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/querying-parquet-files/">Querying Parquet Files</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/querying-plain-text-files/">Querying Plain Text Files</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/querying-directories/">Querying Directories</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/querying-hbase/">Querying HBase</a></li>
-
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">Querying
Complex Data</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/querying-complex-data-introduction/">Querying Complex Data
Introduction</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/sample-data-donuts/">Sample Data: Donuts</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/selecting-flat-data/">Selecting Flat Data</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/using-sql-functions-clauses-and-joins/">Using SQL Functions,
Clauses, and Joins</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/selecting-nested-data-for-a-column/">Selecting Nested Data for a
Column</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/selecting-multiple-columns-within-nested-data/">Selecting Multiple
Columns Within Nested Data</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/querying-hive/">Querying Hive</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/querying-the-information-schema/">Querying the INFORMATION
SCHEMA</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/querying-system-tables/">Querying System Tables</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/monitoring-and-canceling-queries-in-the-drill-web-ui/">Monitoring
and Canceling Queries in the Drill Web UI</a></li>
-
-
- </ul>
-
-
-
- <li class="toctree-l1"><a href="javascript: void(0);">SQL
Reference</a></li>
- <ul style="display: none">
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/sql-reference-introduction/">SQL Reference Introduction</a></li>
-
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">Data
Types</a></li>
- <ul style="">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/supported-data-types/">Supported Data Types</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/date-time-and-timestamp/">Date, Time, and Timestamp</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/handling-different-data-types/">Handling Different Data
Types</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/lexical-structure/">Lexical Structure</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/operators/">Operators</a></li>
-
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">SQL
Functions</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/about-sql-function-examples/">About SQL Function Examples</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/math-and-trig/">Math and Trig</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/data-type-conversion/">Data Type Conversion</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/date-time-functions-and-arithmetic/">Date/Time Functions and
Arithmetic</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/string-manipulation/">String Manipulation</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/aggregate-and-aggregate-statistical/">Aggregate and Aggregate
Statistical</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/functions-for-handling-nulls/">Functions for Handling Nulls</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">Nested
Data Functions</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/nested-data-limitations/">Nested Data Limitations</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/flatten/">FLATTEN</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/kvgen/">KVGEN</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/repeated-count/">REPEATED_COUNT</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/repeated-contains/">REPEATED_CONTAINS</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/query-directory-functions/">Query Directory Functions</a></li>
-
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">SQL
Commands</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/supported-sql-commands/">Supported SQL Commands</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/alter-session-command/">ALTER SESSION Command</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/alter-system-command/">ALTER SYSTEM Command</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/create-table-as-ctas-command/">CREATE TABLE AS (CTAS)
command</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/create-view-command/">CREATE VIEW command</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/describe-command/">DESCRIBE Command</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/explain-commands/">EXPLAIN commands</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/select-statements/">SELECT Statements</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/show-databases-and-show-schemas-command/">SHOW DATABASES AND SHOW
SCHEMAS Command</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/show-files-command/">SHOW FILES Command</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/show-tables-command/">SHOW TABLES Command</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/use-command/">USE Command</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">SQL
Conditional Expressions</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/case/">CASE</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/reserved-keywords/">Reserved Keywords</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/sql-extensions/">SQL Extensions</a></li>
-
-
- </ul>
-
-
-
- <li class="toctree-l1"><a href="javascript: void(0);">Data Sources
and File Formats</a></li>
- <ul style="display: none">
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/data-sources-and-file-formats-introduction/">Data Sources and File
Formats Introduction</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/hive-to-drill-data-type-mapping/">Hive-to-Drill Data Type
Mapping</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/deploying-and-using-a-hive-udf/">Deploying and Using a Hive
UDF</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/parquet-format/">Parquet Format</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/json-data-model/">JSON Data Model</a></li>
-
-
- </ul>
-
-
-
- <li class="toctree-l1"><a href="javascript: void(0);">Develop Custom
Functions</a></li>
- <ul style="display: none">
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/develop-custom-functions-introduction/">Develop Custom Functions
Introduction</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/develop-a-simple-function/">Develop a Simple Function</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/developing-an-aggregate-function/">Developing an Aggregate
Function</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/adding-custom-functions-to-drill/">Adding Custom Functions to
Drill</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/using-custom-functions-in-queries/">Using Custom Functions in
Queries</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/custom-function-interfaces/">Custom Function Interfaces</a></li>
-
-
- </ul>
-
-
-
- <li class="toctree-l1"><a href="javascript: void(0);">Developer
Information</a></li>
- <ul style="display: none">
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">Develop
Drill</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/compiling-drill-from-source/">Compiling Drill from Source</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/drill-patch-review-tool/">Drill Patch Review Tool</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">Contribute
to Drill</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/apache-drill-contribution-guidelines/">Apache Drill Contribution
Guidelines</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/apache-drill-contribution-ideas/">Apache Drill Contribution
Ideas</a></li>
-
- </ul>
-
-
-
- <li class="toctree-l2"><a href="javascript: void(0);">Design
Docs</a></li>
- <ul style="display: none">
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/drill-plan-syntax/">Drill Plan Syntax</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/rpc-overview/">RPC Overview</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/query-stages/">Query Stages</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/useful-research/">Useful Research</a></li>
-
- <li class="toctree-l3"><a class="reference internal"
href="/docs/value-vectors/">Value Vectors</a></li>
-
- </ul>
-
-
- </ul>
-
-
-
- <li class="toctree-l1"><a href="javascript: void(0);">Release
Notes</a></li>
- <ul style="display: none">
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/apache-drill-0-5-0-release-notes/">Apache Drill 0.5.0 Release
Notes</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/apache-drill-0-4-0-release-notes/">Apache Drill 0.4.0 Release
Notes</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/apache-drill-m1-release-notes-apache-drill-alpha/">Apache Drill M1
Release Notes (Apache Drill Alpha)</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/apache-drill-m1-release-notes-apache-drill-alpha/">Apache Drill M1
Release Notes (Apache Drill Alpha)</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/apache-drill-0-6-0-release-notes/">Apache Drill 0.6.0 Release
Notes</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/apache-drill-0-7-0-release-notes/">Apache Drill 0.7.0 Release
Notes</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/apache-drill-0-8-0-release-notes/">Apache Drill 0.8.0 Release
Notes</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/apache-drill-0-9-0-release-notes/">Apache Drill 0.9.0 Release
Notes</a></li>
-
-
- </ul>
-
-
-
- <li class="toctree-l1"><a href="javascript: void(0);">Sample
Datasets</a></li>
- <ul style="display: none">
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/aol-search/">AOL Search</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/enron-emails/">Enron Emails</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/wikipedia-edit-history/">Wikipedia Edit History</a></li>
-
-
- </ul>
-
-
-
- <li class="toctree-l1"><a href="javascript: void(0);">Archived
Pages</a></li>
- <ul style="display: none">
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/how-to-run-the-drill-demo/">How to Run the Drill Demo</a></li>
-
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/what-is-apache-drill/">What is Apache Drill</a></li>
-
-
- </ul>
-
-
-
- <li class="toctree-l1"><a href="javascript: void(0);">Progress
Reports</a></li>
- <ul style="display: none">
-
-
- <li class="toctree-l2"><a class="reference internal"
href="/docs/2014-q1-drill-report/">2014 Q1 Drill Report</a></li>
-
-
- </ul>
-
-
-
- <li class="toctree-l1"><a class="reference internal"
href="/docs/project-bylaws/">Project Bylaws</a></li>
-
-
- </ul>
-
- </div>
- </div>
-</aside>
-
-
- <nav class="breadcrumbs">
- <li><a href="/docs/">Docs</a></li>
-
-
- <li><a href="/docs/tutorials/">Tutorials</a></li>
-
- <li><a href="/docs/learn-drill-with-the-mapr-sandbox/">Learn Drill with
the MapR Sandbox</a></li>
-
- <li>Lession 3: Run Queries on Complex Data Types</li>
-</nav>
-
- <div class="main-content-wrapper">
- <div class="main-content">
-
-
- <a class="edit-link"
href="https://github.com/apache/drill/blob/gh-pages/_docs/tutorials/learn-drill-with-the-mapr-sandbox/050-lesson-3-run-queries-on-complex-data-types.md"
target="_blank"><i class="fa fa-pencil-square-o"></i></a>
-
-
- <div class="int_title">
- <h1>Lession 3: Run Queries on Complex Data Types</h1>
-
- </div>
-
- <link href="/css/docpage.css" rel="stylesheet" type="text/css">
-
- <div class="int_text" align="left">
-
- <h2 id="goal">Goal</h2>
-
-<p>This lesson focuses on queries that exercise functions and operators on
self-
-describing data and complex data types. Drill offers intuitive SQL extensions
-to work with such data and offers high query performance with an architecture
-built from the ground up for complex data.</p>
-
-<h2 id="queries-in-this-lesson">Queries in This Lesson</h2>
-
-<p>Now that you have run ANSI SQL queries against different tables and files
with
-relational data, you can try some examples including complex types.</p>
-
-<ul>
-<li>Access directories and subdirectories of files in a single SELECT
statement.</li>
-<li>Demonstrate simple ways to access complex data in JSON files.</li>
-<li>Demonstrate the repeated_count function to aggregate values in an
array.</li>
-</ul>
-
-<h2 id="query-partitioned-directories">Query Partitioned Directories</h2>
-
-<p>You can use special variables in Drill to refer to subdirectories in your
-workspace path:</p>
-
-<ul>
-<li>dir0</li>
-<li>dir1</li>
-<li>â¦</li>
-</ul>
-
-<p>Note that these variables are dynamically determined based on the
partitioning
-of the file system. No up-front definitions are required on what partitions
-exist. Here is a visual example of how this works:</p>
-
-<p><img src="/docs/img/example_query.png" alt="drill query flow"></p>
-
-<h3 id="set-workspace-to-dfs.logs:">Set workspace to dfs.logs:</h3>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> use dfs.logs;
-+------------+------------+
-| ok | summary |
-+------------+------------+
-| true | Default schema changed to 'dfs.logs' |
-+------------+------------+
-</code></pre></div>
-<h3 id="query-logs-data-for-a-specific-year:">Query logs data for a specific
year:</h3>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> select * from logs where dir0='2013' limit 10;
-+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+
-| dir0 | dir1 | trans_id | date | time | cust_id
| device | state | camp_id | keywords | prod_id | purch_flag |
-+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+
-| 2013 | 2 | 12115 | 02/23/2013 | 19:48:24 | 3
| IOS5 | az | 5 | who's | 6 | false
|
-| 2013 | 2 | 12127 | 02/26/2013 | 19:42:03 | 11459
| IOS5 | wa | 10 | for | 331 | false |
-| 2013 | 2 | 12138 | 02/09/2013 | 05:49:01 | 1
| IOS6 | ca | 7 | minutes | 500 | false |
-| 2013 | 2 | 12139 | 02/23/2013 | 06:58:20 | 1
| AOS4.4 | ms | 7 | i | 20 | false |
-| 2013 | 2 | 12145 | 02/10/2013 | 10:14:56 | 10
| IOS5 | mi | 6 | wrong | 42 | false |
-| 2013 | 2 | 12157 | 02/15/2013 | 02:49:22 | 102
| IOS5 | ny | 5 | want | 95 | false |
-| 2013 | 2 | 12176 | 02/19/2013 | 08:39:02 | 28
| IOS5 | or | 0 | and | 351 | false |
-| 2013 | 2 | 12194 | 02/24/2013 | 08:26:17 | 125445
| IOS5 | ar | 0 | say | 500 | true |
-| 2013 | 2 | 12236 | 02/05/2013 | 01:40:05 | 10
| IOS5 | nj | 2 | sir | 393 | false |
-| 2013 | 2 | 12249 | 02/03/2013 | 04:45:47 | 21725
| IOS5 | nj | 5 | no | 414 | false |
-+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+
-</code></pre></div>
-<p>This query constrains files inside the subdirectory named 2013. The variable
-dir0 refers to the first level down from logs, dir1 to the next level, and so
-on. So this query returned 10 of the rows for February 2013.</p>
-
-<h3
id="further-constrain-the-results-using-multiple-predicates-in-the-query:">Further
constrain the results using multiple predicates in the query:</h3>
-
-<p>This query returns a list of customer IDs for people who made a purchase via
-an IOS5 device in August 2013.</p>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> select dir0 as yr, dir1 as mth, cust_id from logs
-where dir0='2013' and dir1='8' and device='IOS5' and
purch_flag='true'
-order by `date`;
-+------------+------------+------------+
-| yr | mth | cust_id |
-+------------+------------+------------+
-| 2013 | 8 | 4 |
-| 2013 | 8 | 521 |
-| 2013 | 8 | 1 |
-| 2013 | 8 | 2 |
-
-...
-</code></pre></div>
-<h3 id="return-monthly-counts-per-customer-for-a-given-year:">Return monthly
counts per customer for a given year:</h3>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> select cust_id, dir1 month_no, count(*) month_count from logs
-where dir0=2014 group by cust_id, dir1 order by cust_id, month_no limit 10;
-+------------+------------+-------------+
-| cust_id | month_no | month_count |
-+------------+------------+-------------+
-| 0 | 1 | 143 |
-| 0 | 2 | 118 |
-| 0 | 3 | 117 |
-| 0 | 4 | 115 |
-| 0 | 5 | 137 |
-| 0 | 6 | 117 |
-| 0 | 7 | 142 |
-| 0 | 8 | 19 |
-| 1 | 1 | 66 |
-| 1 | 2 | 59 |
-+------------+------------+-------------+
-10 rows selected
-</code></pre></div>
-<p>This query groups the aggregate function by customer ID and month for one
-year: 2014.</p>
-
-<h2 id="query-complex-data">Query Complex Data</h2>
-
-<p>Drill provides some specialized operators and functions that you can use to
-analyze nested data natively without transformation. If you are familiar with
-JavaScript notation, you will already know how some of these extensions
work.</p>
-
-<h3 id="set-the-workspace-to-dfs.clicks:">Set the workspace to dfs.clicks:</h3>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> use dfs.clicks;
-+------------+------------+
-| ok | summary |
-+------------+------------+
-| true | Default schema changed to 'dfs.clicks' |
-+------------+------------+
-</code></pre></div>
-<h3 id="explore-clickstream-data:">Explore clickstream data:</h3>
-
-<p>Note that the user_info and trans_info columns contain nested data: arrays
and
-arrays within arrays. The following queries show how to access this complex
-data.</p>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> select * from `clicks/clicks.json` limit 5;
-+------------+------------+------------+------------+------------+
-| trans_id | date | time | user_info | trans_info |
-+------------+------------+------------+------------+------------+
-| 31920 | 2014-04-26 | 12:17:12 |
{"cust_id":22526,"device":"IOS5","state":"il"}
| {"prod_id":[174,2],"purch_flag":"false"} |
-| 31026 | 2014-04-20 | 13:50:29 |
{"cust_id":16368,"device":"AOS4.2","state":"nc"}
| {"prod_id":[],"purch_flag":"false"} |
-| 33848 | 2014-04-10 | 04:44:42 |
{"cust_id":21449,"device":"IOS6","state":"oh"}
| {"prod_id":[582],"purch_flag":"false"} |
-| 32383 | 2014-04-18 | 06:27:47 |
{"cust_id":20323,"device":"IOS5","state":"oh"}
| {"prod_id":[710,47],"purch_flag":"false"} |
-| 32359 | 2014-04-19 | 23:13:25 |
{"cust_id":15360,"device":"IOS5","state":"ca"}
| {"prod_id":
[0,8,170,173,1,124,46,764,30,711,0,3,25],"purch_flag":"true"}
|
-+------------+------------+------------+------------+------------+
-</code></pre></div>
-<h3 id="unpack-the-user_info-column:">Unpack the user_info column:</h3>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> select t.user_info.cust_id as custid, t.user_info.device as
device,
-t.user_info.state as state
-from `clicks/clicks.json` t limit 5;
-+------------+------------+------------+
-| custid | device | state |
-+------------+------------+------------+
-| 22526 | IOS5 | il |
-| 16368 | AOS4.2 | nc |
-| 21449 | IOS6 | oh |
-| 20323 | IOS5 | oh |
-| 15360 | IOS5 | ca |
-+------------+------------+------------+
-</code></pre></div>
-<p>This query uses a simple table.column.column notation to extract nested
column
-data. For example:</p>
-<div class="highlight"><pre><code class="language-text"
data-lang="text">t.user_info.cust_id
-</code></pre></div>
-<p>where <code>t</code> is the table alias provided in the query,
<code>user_info</code> is a top-level
-column name, and <code>cust_id</code> is a nested column name.</p>
-
-<p>The table alias is required; otherwise column names such as
<code>user_info</code> are
-parsed as table names by the SQL parser.</p>
-
-<h3 id="unpack-the-trans_info-column:">Unpack the trans_info column:</h3>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> select t.trans_info.prod_id as prodid, t.trans_info.purch_flag
as
-purchased
-from `clicks/clicks.json` t limit 5;
-+------------+------------+
-| prodid | purchased |
-+------------+------------+
-| [174,2] | false |
-| [] | false |
-| [582] | false |
-| [710,47] | false |
-| [0,8,170,173,1,124,46,764,30,711,0,3,25] | true |
- 5 rows selected
-</code></pre></div>
-<p>Note that this result reveals that the prod_id column contains an array of
IDs
-(one or more product ID values per row, separated by commas). The next step
-shows how you to access this kind of data.</p>
-
-<h2 id="query-arrays">Query Arrays</h2>
-
-<p>Now use the [n] notation, where n is the position of the value in an array,
-starting from position 0 (not 1) for the first value. You can use this
-notation to write interesting queries against nested array data.</p>
-
-<p>For example:</p>
-<div class="highlight"><pre><code class="language-text"
data-lang="text">trans_info.prod_id[0]
-</code></pre></div>
-<p>refers to the first value in the nested prod_id column and</p>
-<div class="highlight"><pre><code class="language-text"
data-lang="text">trans_info.prod_id[20]
-</code></pre></div>
-<p>refers to the 21st value, assuming one exists.</p>
-
-<h3 id="find-the-first-product-that-is-searched-for-in-each-transaction:">Find
the first product that is searched for in each transaction:</h3>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> select t.trans_id, t.trans_info.prod_id[0] from
`clicks/clicks.json` t limit 5;
-+------------+------------+
-| trans_id | EXPR$1 |
-+------------+------------+
-| 31920 | 174 |
-| 31026 | null |
-| 33848 | 582 |
-| 32383 | 710 |
-| 32359 | 0 |
-+------------+------------+
-5 rows selected
-</code></pre></div>
-<h3
id="for-which-transactions-did-customers-search-on-at-least-21-products?">For
which transactions did customers search on at least 21 products?</h3>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> select t.trans_id, t.trans_info.prod_id[20]
-from `clicks/clicks.json` t
-where t.trans_info.prod_id[20] is not null
-order by trans_id limit 5;
-+------------+------------+
-| trans_id | EXPR$1 |
-+------------+------------+
-| 10328 | 0 |
-| 10380 | 23 |
-| 10701 | 1 |
-| 11100 | 0 |
-| 11219 | 46 |
-+------------+------------+
-5 rows selected
-</code></pre></div>
-<p>This query returns transaction IDs and product IDs for records that contain
a
-non-null product ID at the 21st position in the array.</p>
-
-<h3 id="return-clicks-for-a-specific-product-range:">Return clicks for a
specific product range:</h3>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> select * from (select t.trans_id, t.trans_info.prod_id[0] as
prodid,
-t.trans_info.purch_flag as purchased
-from `clicks/clicks.json` t) sq
-where sq.prodid between 700 and 750 and sq.purchased='true'
-order by sq.prodid;
-+------------+------------+------------+
-| trans_id | prodid | purchased |
-+------------+------------+------------+
-| 21886 | 704 | true |
-| 20674 | 708 | true |
-| 22158 | 709 | true |
-| 34089 | 714 | true |
-| 22545 | 714 | true |
-| 37500 | 717 | true |
-| 36595 | 718 | true |
-...
-</code></pre></div>
-<p>This query assumes that there is some meaning to the array (that it is an
-ordered list of products purchased rather than a random list).</p>
-
-<h2 id="perform-operations-on-arrays">Perform Operations on Arrays</h2>
-
-<h3
id="rank-successful-click-conversions-and-count-product-searches-for-each-session:">Rank
successful click conversions and count product searches for each session:</h3>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> select t.trans_id, t.`date` as session_date,
t.user_info.cust_id as
-cust_id, t.user_info.device as device, repeated_count(t.trans_info.prod_id) as
-prod_count, t.trans_info.purch_flag as purch_flag
-from `clicks/clicks.json` t
-where t.trans_info.purch_flag = 'true' order by prod_count desc;
-+------------+--------------+------------+------------+------------+------------+
-| trans_id | session_date | cust_id | device | prod_count |
purch_flag |
-+------------+--------------+------------+------------+------------+------------+
-| 37426 | 2014-04-06 | 18709 | IOS5 | 34 | true
|
-| 31589 | 2014-04-16 | 18576 | IOS6 | 31 | true
|
-| 11600 | 2014-04-07 | 4260 | AOS4.2 | 28 | true
|
-| 35074 | 2014-04-03 | 16697 | AOS4.3 | 27 | true
|
-| 17192 | 2014-04-22 | 2501 | AOS4.2 | 26 | true
|
-...
-</code></pre></div>
-<p>This query uses an SQL extension, the repeated_count function, to get an
-aggregated count of the array values. The query returns the number of products
-searched for each session that converted into a purchase and ranks the counts
-in descending order. Only clicks that have resulted in a purchase are
counted.</p>
-
-<h2 id="store-a-result-set-in-a-table-for-reuse-and-analysis">Store a Result
Set in a Table for Reuse and Analysis</h2>
-
-<p>Finally, run another correlated subquery that returns a fairly large result
-set. To facilitate additional analysis on this result set, you can easily and
-quickly create a Drill table from the results of the query.</p>
-
-<h3 id="continue-to-use-the-dfs.clicks-workspace">Continue to use the
dfs.clicks workspace</h3>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> use dfs.clicks;
-+------------+------------+
-| ok | summary |
-+------------+------------+
-| true | Default schema changed to 'dfs.clicks' |
-+------------+------------+
-</code></pre></div>
-<h3 id="return-product-searches-for-high-value-customers:">Return product
searches for high-value customers:</h3>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> select o.cust_id, o.order_total, t.trans_info.prod_id[0] as
prod_id
-from hive.orders as o, `clicks/clicks.json` t
-where o.cust_id=t.user_info.cust_id
-and o.order_total > (select avg(inord.order_total)
-from hive.orders inord where inord.state = o.state);
-+------------+-------------+------------+
-| cust_id | order_total | prod_id |
-+------------+-------------+------------+
-...
-| 9650 | 69 | 16 |
-| 9650 | 69 | 560 |
-| 9650 | 69 | 959 |
-| 9654 | 76 | 768 |
-| 9656 | 76 | 32 |
-| 9656 | 76 | 16 |
-...
-+------------+-------------+------------+
-106,281 rows selected
-</code></pre></div>
-<p>This query returns a list of products that are being searched for by
customers
-who have made transactions that are above the average in their states.</p>
-
-<h3 id="materialize-the-result-of-the-previous-query:">Materialize the result
of the previous query:</h3>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> create table product_search as select o.cust_id, o.order_total,
t.trans_info.prod_id[0] as prod_id
-from hive.orders as o, `clicks/clicks.json` t
-where o.cust_id=t.user_info.cust_id and o.order_total > (select
avg(inord.order_total)
-from hive.orders inord where inord.state = o.state);
-+------------+---------------------------+
-| Fragment | Number of records written |
-+------------+---------------------------+
-| 0_0 | 106281 |
-+------------+---------------------------+
-1 row selected
-</code></pre></div>
-<p>This example uses a CTAS statement to create a table based on a correlated
-subquery that you ran previously. This table contains all of the rows that the
-query returns (106,281) and stores them in the format specified by the storage
-plugin (Parquet format in this example). You can create tables that store data
-in csv, parquet, and json formats.</p>
-
-<h3 id="query-the-new-table-to-verify-the-row-count:">Query the new table to
verify the row count:</h3>
-
-<p>This example simply checks that the CTAS statement worked by verifying the
-number of rows in the table.</p>
-<div class="highlight"><pre><code class="language-text" data-lang="text">0:
jdbc:drill:> select count(*) from product_search;
-+------------+
-| EXPR$0 |
-+------------+
-| 106281 |
-+------------+
-1 row selected
-</code></pre></div>
-<h3 id="find-the-storage-file-for-the-table:">Find the storage file for the
table:</h3>
-<div class="highlight"><pre><code class="language-text"
data-lang="text">[root@maprdemo product_search]# cd
/mapr/demo.mapr.com/data/nested/product_search
-[root@maprdemo product_search]# ls -la
-total 451
-drwxr-xr-x. 2 mapr mapr 1 Sep 15 13:41 .
-drwxr-xr-x. 4 root root 2 Sep 15 13:41 ..
--rwxr-xr-x. 1 mapr mapr 460715 Sep 15 13:41 0_0_0.parquet
-</code></pre></div>
-<p>Note that the table is stored in a file called <code>0_0_0.parquet</code>.
This file is
-stored in the location defined by the dfs.clicks workspace:</p>
-<div class="highlight"><pre><code class="language-text"
data-lang="text">"location":
"http://demo.mapr.com/data/nested"
-</code></pre></div>
-<p>with a subdirectory that has the same name as the table you created.</p>
-
-<h2 id="what's-next">What's Next</h2>
-
-<p>Complete the tutorial with the <a href="/docs/summary">Summary</a>.</p>
-
-
-
- <div class="doc-nav">
-
- <span class="previous-toc"><a
href="/docs/lession-2-run-queries-with-ansi-sql/">â Lession 2: Run Queries
with ANSI SQL</a></span><span class="next-toc"><a href="/docs/summary/">Summary
â</a></span>
-</div>
-
-
- </div>
- </div>
- </div>
-
- </div>
- <p class="push"></p>
-<div id="footer" class="mw">
-<div class="wrapper">
-Copyright © 2012-2014 The Apache Software Foundation, licensed under the
Apache License, Version 2.0.<br>
-Apache and the Apache feather logo are trademarks of The Apache Software
Foundation. Other names appearing on the site may be trademarks of their
respective owners.<br/><br/>
-</div>
-</div>
-
- <script>
-(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
-(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
-m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
-})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
-
-ga('create', 'UA-53379651-1', 'auto');
-ga('send', 'pageview');
-</script>
-
-</body>
-</html>