0% found this document useful (0 votes)
7 views

Practical 6 (BDA) ETI

The document outlines various methods for loading data into Hive tables, including loading from local and HDFS file systems, copying data within HDFS, and using Sqoop for importing data from relational databases. Each method is explained with corresponding code examples and their implications for data management in Hive. The conclusion emphasizes the flexibility of Apache Hive in accommodating different data sources and storage systems.

Uploaded by

gx59368
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Practical 6 (BDA) ETI

The document outlines various methods for loading data into Hive tables, including loading from local and HDFS file systems, copying data within HDFS, and using Sqoop for importing data from relational databases. Each method is explained with corresponding code examples and their implications for data management in Hive. The conclusion emphasizes the flexibility of Apache Hive in accommodating different data sources and storage systems.

Uploaded by

gx59368
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

PRACTICAL 6

Aim: Load the data into Hive Table:

a) Load data from Local file system:


Code:
LOAD DATA LOCAL INPATH '/path/to/local/file' OVERWRITE INTO TABLE hive_table;

This command loads data from a file stored in the local file system into the Hive table
hive_table. The OVERWRITE keyword indicates that any existing data in the table
should be overwritten with the new data.

b) Load data from HDFS file system:


Code:
LOAD DATA INPATH '/path/to/hdfs/file' OVERWRITE INTO TABLE hive_table;

Similar to loading data from the local file system, this command loads data from a file
stored in Hadoop Distributed File System (HDFS) into the Hive table hive_table.

c) Copy data to Hive table Location:


Code:
hadoop fs -cp /path/to/source/file /hive/warehouse/hive_table

This command copies data from a source file in HDFS to the location of the Hive table
hive_table. After copying the data, it becomes accessible to the Hive table for querying
and analysis.

d) Sqoop Hive import to import table data:


Code:
sqoop import --connect jdbc:mysql://hostname/dbname \
--username username --password password \
--table tablename \
--hive-import \
--hive-table hive_table \
--hive-overwrite
This command uses Apache Sqoop to import data from a relational database (e.g.,
MySQL) into a Hive table named hive_table. Sqoop automatically performs the necessary
data conversion and imports the data into the Hive table location specified.

Conclusion: Apache Hive offers multiple methods for loading data into Hive tables, providing
flexibility and adaptability to various data sources and storage systems.
 Loading data from the local file system or Hadoop Distributed File System (HDFS) allows for
straightforward ingestion of data stored in files directly into Hive tables. This method is
suitable for scenarios where data is already available in files on the local system or within the
Hadoop environment.
 Copying data to the Hive table location in HDFS provides an alternative approach to loading
data, allowing users to move data from one location to another within the Hadoop ecosystem.
This method is useful when data needs to be transferred or consolidated within the Hadoop
cluster before being accessed by Hive.
 Utilizing Sqoop for Hive import enables seamless integration with external data sources, such
as relational databases. Sqoop automates the process of importing data into Hive tables,
handling data conversion and transfer from relational databases to Hive. This method is
beneficial for scenarios where data resides in external databases and needs to be analyzed
within the Hive environment.
Process Related Product Related Total Marks (25) Signature
(15) (10)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy