Hive interview questions

15. What are the different types of Tables in Hive ?
A Hive table is logically made up of the data being stored and the associated metadata describing the layout of the data in the table.Hive stores the metadata in a relational database – and not in HDFS, hive use an embedded Derby database to store metadata information.The Metastore stores all the information about the tables, their partitions, the schemas, the columns and their types, the table locations etc. This information can be queried or modified using a thrift interface and as a result it can be called from clients in different programming languages.

16. Explain Managed Tables and External Tables ?
When you create a table in Hive, by default Hive will manage the data, which means that Hive moves the data into its warehouse directory. Alternatively, you may create an external table, which tells Hive to refer to the data that is at an existing location outside the warehouse directory. The difference between the two table types is seen in the LOAD and DROP semantics.

CREATE TABLE managed_table (dummy STRING);
LOAD DATA INPATH ‘/user/tom/data.txt’ INTO table managed_table;
will move the file hdfs://user/tom/data.txt into Hive’s warehouse directory for the
managed_table table, which is hdfs://user/hive/warehouse/managed_table.5

An external table behaves differently. You control the creation and deletion of the data.
The location of the external data is specified at table creation time:
CREATE EXTERNAL TABLE external_table (dummy STRING)
LOCATION ‘/user/tom/external_table’;
LOAD DATA INPATH ‘/user/tom/data.txt’ INTO TABLE external_table;

17. What are the different types of tables available in HIve?
There are two types. Managed table and external table. In managed table both the data an schema in under control of hive but in external table only the schema is under control of Hive.

18. Is Hive suitable to be used for OLTP systems? Why?
No Hive does not provide insert and update at row level. So it is not suitable for OLTP system.

19. Can a table be renamed in Hive?
Alter Table table_name RENAME TO new_name
ALTER TABLE log_messages RENAME TO logmsgs;

20. Can we change the data type of a column in a hive table?
Using REPLACE column option
ALTER TABLE table_name REPLACE COLUMNS ……
ALTER TABLE log_messages REPLACE COLUMNS (
hours_mins_secs INT COMMENT ‘hour, minute, seconds from timestamp’,
severity STRING COMMENT ‘The message severity’
message STRING COMMENT ‘The rest of the message’);

21. What is a metastore in Hive?
It is a relational database storing the metadata of hive tables, partitions, Hive databases etc.

Author: user

Leave a Reply

Your email address will not be published. Required fields are marked *