GithubHelp home page GithubHelp logo

hive-demo's Introduction

DEMO

  • Docker Hive setup
  • Process and manipulate HDFS Data via Hive

HIVE Setup

  1. Running Docker image
git clone https://github.com/big-data-europe/docker-hive
cd docker-hive
docker-compose up -d

The image contains:

  • Namenode
  • datanode
  • Hive Server
  • Hive metastore configured with PostgreSQL
  • ..

After setting it up, we can access Hive and namenode servers:

#list running images
docker ps

# access Hive serve via bash terminal
docker exec -it docker-hive_hive-server_1 bash

# access Namenode serve via bash terminal ( so we can add some files to HDFS ...)
docker exec -it docker-hive_namenode_1 bash
  1. Creating database/tables in Hive
# creating a database
create database bdcc_demo;

# list databases
show databases;

# use the database 'bdcc_demo' that we've just created
use bdcc_demo;

# creating 'students' table
create table students(firstname String, lastname String, age INT) row format delimited fields terminated by ',' stored as textfile;

# show 'students' table information
describe students;


# add some data to HDFS ( following the 'students' table schema)
hdfs dfs -mkdir -p /user/data

# create a text file
touch data.txt

# opening it in Vim to add some data in it. ex: john,doe,20
vim data.txt

# copy the file from local filesystem to HDFS
hdfs dfs -put data.txt /user/data


# Import Data to Hive

# METHOD 1: this will move our data to Hive warehouse

LOAD DATA INPATH '/user/data/data.txt' OVERWRITE INTO TABLE students;


# show 'students' table data;
select * from students;

# METHOD 2: This will keep data in its original path without moving it. and Hive will read it from that path.
# creating external table
create external table students2(nom String, prenom String, age INT) row format delimited fields terminated by ',' LOCATION '/user/data';

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.