Hive Flashcards

1
Q

What is Hive?

A

Data warehouse system built on top of Hadoop for querying and analyzing large datasets.
It is not a relational database nor it is designed for online transaction processing.

You can access data via SQL-like queries (HiveQL)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the data units in Hive?

A

Databases
Tables
Partitions which speeds up the update and retrieval. Nested sub-directories in HDFS
Buckets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Does Hive support ACID transactions?

A

Yes but it has to be enabled globally.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are Hive Components?

A

User Interface: UI to submit queries.
Server: Accepts requests from different clients and provides it to the Hive Driver.
Driver: Receives the queries.
Compiler: Parses the queries and generates an execution plan
Metastore: Attributes of tables like location in HDFS
Execution Engine: Executes the execution plan created by the compiler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why is HDFS is not used by the Hive metastore?

A

The storage system for the metastore should be optimized for online transactions with random accesses and updates. A file system like HDFS is not suited since it is optimized for sequential scans and not for random access.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between external table and managed table?

A

External Table: Hive is responsible for managing only table metadata; not the table data. While dropping the table, Hive just deletes the metadata information leaving the table data untouched.

Managed Table: Hive is responsible for managing the table data. While dropping the table, metadata and table data is deleted from the Hive warehouse.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When should we use SORT BY instead of ORDER BY?

A

Both do the same thing but SORT BY uses multiple reducers whereas ORDER BY uses a single reducer. Therefore SORT BY should be used to sort huge datasets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the difference between a partition and a bucket in Hive?

A

Partition is like creating directories. It changes how Hive structures the data storage. Works best when the cardinality of the field is not high, otherwise you will end up having lots of directories.
Cardinality refers to the number of possible values a field can have. (For example country would have like 300 values but timestamp would have billions)
Bucket is like a sub-partition where you split the data into more manageable parts but it is helpful when a field has high cardinality.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is dynamic partitioning?

A

Values of partitions are not known before hand

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Where does the data of a Hive table gets stored?

A

Gets stored in an HDFS directory (/user/hive/warehouse) by default

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Can Hive be used in OLTP systems?

A

Hive does not support row-level data insertion so it is not suitable for us in OLTP systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is UDF in Hive?

A

It is a User Defined Function created with Java that allows to create custom functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly