---
title: "Short note: Pig and Hive"
subject: "Big Data Technologies"
chapter: 6
key: "semester_8/big_data_technologies:short-note-pig-hive"
source: https://www.bctengineer.com/q/semester_8/big_data_technologies/short-note-pig-hive
site: BCT Engineering
---

# Short note: Pig and Hive

Big Data Technologies · Chapter 6: Case Study: Hadoop

- Asked in: 2075 Bhadra, 5 marks
- Video: [PIG AND HIVE (BIG DATA)](https://www.youtube.com/watch?v=A9bUYuBZmv4) — Tech Trek
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_8/big_data_technologies/short-note-pig-hive
- Whole chapter: https://www.bctengineer.com/md/semester_8/big_data_technologies/chapter-6

## Question

Write a short note on Pig and Hive.

## Short answer

Pig is a data-flow scripting platform using Pig Latin, compiled into MapReduce jobs, good for ETL. Hive is a data warehouse providing SQL-like HiveQL queries over HDFS, with metadata in the Metastore, suited for batch reporting.

## Answer

#### Apache Pig

**Pig** is a high-level data-flow platform for analysing large data sets in Hadoop, developed at Yahoo. Programs are written in **Pig Latin**, a scripting language, which the Pig engine compiles into MapReduce jobs. It is good for ETL and for programmers who want to avoid writing long Java MapReduce code. It handles structured and unstructured data.

```text
A = LOAD 'students.txt' USING PigStorage(',')
    AS (name:chararray, college:chararray, marks:int);
B = GROUP A BY college;
C = FOREACH B GENERATE group, MAX(A.marks);
DUMP C;
```

Modes: local mode and MapReduce mode. Features: fewer lines of code, built-in operators (JOIN, GROUP, FILTER, ORDER), and user-defined functions.

#### Apache Hive

**Hive** is a data warehouse system on top of Hadoop, developed at Facebook. It provides a SQL-like language, **HiveQL**, for querying and managing data stored in HDFS. Queries are converted to MapReduce (or Tez/Spark) jobs. Table metadata is kept in the **Metastore**.

```text
CREATE TABLE students (name STRING, college STRING, marks INT)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
SELECT college, MAX(marks) FROM students GROUP BY college;
```

It suits batch analysis and reporting by SQL users, but is not for real-time, row-level transactions.

#### Comparison

| Point | Pig | Hive |
|---|---|---|
| Language | Pig Latin (procedural, data-flow) | HiveQL (declarative, SQL-like) |
| Users | Programmers, researchers | Analysts, SQL users |
| Schema | Optional | Required (Metastore) |
| Best for | ETL pipelines | Reporting, data warehousing |
| Origin | Yahoo | Facebook |

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is Pig Latin and how does it run?
   A. A SQL dialect that runs only on a single machine
   B. A data-flow scripting language compiled by the Pig engine into MapReduce jobs
   C. A Java API for HDFS
   D. A storage format
   Answer: B. Pig Latin scripts are compiled into MapReduce jobs, reducing the need for long Java code. (Key point: Pig basics)

2. Which describes Hive correctly?
   A. A procedural scripting tool made at Yahoo
   B. A real-time engine for row-level transactions
   C. A data warehouse on Hadoop with SQL-like HiveQL, with table metadata kept in the Metastore
   D. A tool for collecting streaming logs
   Answer: C. Hive converts HiveQL to MapReduce/Tez/Spark and suits batch analysis, not row-level real-time transactions. (Key point: Hive basics)

3. Which comparison between Pig and Hive is correct?
   A. Pig is declarative and needs a schema; Hive is procedural
   B. Pig is procedural data-flow with optional schema, good for ETL; Hive is declarative SQL-like with required schema, good for reporting
   C. Both require the same language
   D. Hive was developed at Yahoo and Pig at Facebook
   Answer: B. Pig (Yahoo) suits programmers and ETL; Hive (Facebook) suits SQL users and warehousing. (Key point: Pig versus Hive)
