Hive | Learn for Master - Part 2
  • Apache Pig Load ORC data from Hive Table

    There are some cases your data is stored in Hive Table, and you may want to process the data using Apache Pig. In this post, I use an example to describe how to read Hive ORC data using Apache Pig. 

    1. We first create Hive table stored as ORC, and load some data into the table.
    2. Then, we develop a Apache Pig script to load the data from the Hive ORC table. 

    Optimized Row Columnar (ORC) file format

    The Optimized Row Columnar (ORC) file format provides a highly efficient way to store Hive data.

    [Read More...]
  • How to get hive table delimiter or schema

    When you have a hive table, you may want to check its delimiter or detailed information such as Schema. There are two solutions:

    Get the delimiter of a Hive Table

    To get the field delimiter of a hive table, we can use the following command:

    Here is an example:

    Get the schema of Hive Table

    Another solution is to use: 

    This will generate a competed information about the table. 

    [Read More...]
  • How to load data from a text file to Hive table

    In this post, I describe how to insert data from a text file to a hive table. 

    Suppose you have tab delimited file::

    Create a Hive table stored as a text file.

    Load the text file (stored locally) into the Hive table:

    Create a Hive table stored as sequence file.

    Now you can load into the sequence table from the text table:

     

    [Read More...]
  • Apache Hive Usage Example – Create Hive Table

    In this post, I describe how to create a Hive Table.

    Create Table Statement

    The syntax and example to create a Hive table is as follows:

    Syntax

    For example, suppose you want to create a Table student, with the following attributes:

    1. id, the student’s ID number, the type is int,
    2. name, the type is String, 
    3. age, the type is int,
    4. score, the type is Float, 

    Note:

    1.  If you’re not currently working in the target database,
    [Read More...]
  • Apache Hive Usage Example – How to Check the Current Hive Database

    To know which Hive database you are currently using, Use the following command:

    then the prompt will display Hive(DB_name)

    Another Method is to edit hive-site.xml by pasting this code:

    In second scenario, you can automatically display the Hive dabatabase name when you open terminal.

    [Read More...]
  • Apache Hive Usage Example – Create and Use Database

    I this post, I describe how  to Create a Hive Database, Create Database using JDBC, Describe and Show hive Database. 

    Create Database Statement

    A database in Hive is a namespace or a collection of tables.  In order to create a database in Hive, we need to use the Create Database statement. The syntax for this statement is as follows:

    CREATE DATABASE|SCHEMA [IF NOT EXISTS] <database name>

    Here, IF NOT EXISTS is an optional clause, which notifies the user that a database with the same name already exists. We can use SCHEMA in place of DATABASE in this command.

    [Read More...]
Page 2 of 212