Book Image

Hadoop MapReduce v2 Cookbook - Second Edition: RAW

Book Image

Hadoop MapReduce v2 Cookbook - Second Edition: RAW

Overview of this book

Table of Contents (19 chapters)
Hadoop MapReduce v2 Cookbook Second Edition
Credits
About the Author
Acknowledgments
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Simple SQL-style data querying using Apache Hive


We can query the datasets that have been mapped to Hive tables using HiveQL, which is similar to SQL. These queries can be simple data-exploration operations such as counts, orderby, and group by as well as complex joins, summarizations, and analytic operations. In this recipe, we'll explore simple data exploration Hive queries. The subsequent recipes in this chapter will present some of the advanced querying use cases.

Getting ready

Install Hive and follow the earlier Creating databases and tables using Hive CLI recipe.

How to do it...

This section demonstrates how to perform a simple SQL-style query using Hive.

  1. Start Hive by issuing the following command:

    $ hive
    
  2. Issue the following query in the Hive CLI to inspect the users aged between 18 and 34. Hive uses a MapReduce job in the background to perform this data-filtering operation:

    hive> SELECT user_id, location, age FROM users WHERE age>18 and age <34 limit 10;                   
    Total...