• No products in the cart.

301.3.5-Hive Basic Vocabulary and Hive Query Language

 

Hive Basic Vocabulary

Databases, Tables and more

  • Databases:
  • Contains tables, views, partitions etc.,
  • Tables:
  • Data records with same schema. For example quarterly month sales data table

Data Types

  • Integers: TINYINT, SMALLINT, INT, BIGINT.
  • Boolean: BOOLEAN.
  • Floating point numbers: FLOAT, DOUBLE .
  • String: STRING.

Hive Query Language

Create table

CREATE TABLE stack_overflow_tags(id BIGINT, title string, body string, tag1 string,tag2 string,tag3 string,tag4 string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'  ESCAPED BY '\\' ;

Next step is to fill the data in table. Make sure that the dataset is on HDFS

dfs -ls / ;

Blank table is created with schema. Now fill the data inside the table.

LOAD DATA INPATH '/stack_overflow_hdfs' INTO TABLE stack_overflow_tags;

Check the data on hive data warehosue

http://localhost:50070/explorer.html#/user/hive/warehouse/stack_overflow_tags

Select first few rows

select * from stack_overflow_tags LIMIT 3;

See below part of the terminal:

Sending the output to a new file

INSERT OVERWRITE LOCAL DIRECTORY '/home/hduser/Output/hive_out1' ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' select * from stack_overflow_tags LIMIT 3;

Have a look at the exported file. Do this in a new (non-hive) terminal

cat /home/hduser/Output/hive_out1/000000_0

 

22nd March 2018

DV Analytics

DV Data & Analytics is a leading data science,  Cyber Security training and consulting firm, led by industry experts. We are aiming to train and prepare resources to acquire the most in-demand data science job opportunities in India and abroad.

Bangalore Center

DV Data & Analytics Bangalore Private Limited
#52, 2nd Floor:
Malleshpalya Maruthinagar Bengaluru.
Bangalore 560075
India
(+91) 9019 030 033 (+91) 8095 881 188
Email: info@dvanalyticsmds.com

Bhubneshwar Center

DV Data & Analytics Private Limited Bhubaneswar
Plot No A/7 :
Adjacent to Maharaja Cine Complex, Bhoinagar, Acharya Vihar
Bhubaneswar 751022
(+91) 8095 881 188 (+91) 8249 430 414
Email: info@dvanalyticsmds.com

top
© 2020. All Rights Reserved.