We are offering a list of industry-designed Apache Hive interview questions to help you ace your Hive job interview. In this interview questions list, you will learn what a Hive variable is, Hive table types, adding nodes in Hive, concatenation function in Hive, changing column data type, Hive query processor components, and Hive bucketing. Learn Big Data Hadoop from Intellipaat's Hadoop Training and fast-track your career!
Hive is an open-source data warehouse system. We can use Hive for analyzing and querying large datasets. It’s similar to SQL. The present version of Hive is 0.13.1. Hive supports ACID (Atomicity, Consistency, Isolation, and Durability) transactions. ACID transactions are provided at row levels. Following are the options Hive uses to support ACID transactions:
Want to learn more about Hive? Go through this insightful blog ‘What is Hive?’
Hive variables are basically created in the Hive environment that is referenced by Hive scripting languages. They allow to pass some values to a Hive query when the query starts executing. They use the source command.
Learn for free ! Subscribe to our youtube Channel.
Hive is not considered a full database. The design rules and regulations of Hadoop and HDFS have put restrictions on what Hive can do. However, Hive is most suitable for data warehouse applications because it:
Although Hive doesn’t provide fundamental features required for Online Transaction Processing (OLTP), it is suitable for data warehouse applications in large datasets. There are two types of tables in Hive:
Get a better understanding of Hive by going through this Hive Tutorial now!
Yes, we can change the settings within a Hive session using the SET command. It helps change the Hive job settings for an exact query. For example, the following command shows that buckets are occupied according to the table definition:
hive> SET hive.enforce.bucketing=true;
We can see the current value of any property by using SET with the property name. SET will list all the properties with their values set by Hive.
hive> SET hive.enforce.bucketing;
This list will not include the defaults of Hadoop. So, we should use the below code:
It will list all the properties including the Hadoop defaults in the system.
Interested in learning Hive? Well, we have a comprehensive master’s Big Data Hadoop Course to give you an idea of all concepts in Hive!
Yes, we can add the nodes by following the below steps:
Step 1: Take a new system; create a new username and password Step 2: Install SSH and with the master node setup SSH connections Step 3: Add ssh public_rsa id key to the authorized keys file Step 4: Add the new DataNode hostname, IP address, and other details in /etc/hosts slaves file:
192.168.1.102 slave3.in slave3
Step 5: Start the DataNode on a new node Step 6: Login to the new node like suhadoop or:
ssh -X [email protected]
Step 7: Start HDFS of the newly added slave node by using the following command:
./bin/hadoop-daemon.sh start data node
Step 8: Check the output of the jps command on the new node
Go through this Hadoop Training in London to get a clear understanding of Hadoop!
The concatenate function will join the input strings. We can specify ‘n’ number of strings separated by a comma.
Every time, we set the limits of the strings by ‘-‘. If it is common for every string, then Hive provides another command:
In this case, we have to specify the set limits of the operator first as follows:
TRIM(‘ INTELLIPAAT ‘);
To remove the leading space:
To remove the trailing space:
We can change the column data type by using ALTER and CHANGE as follows:
ALTER TABLE table_name CHANGE column_namecolumn_namenew_datatype;
For example, if we want to change the data type of the salary column from integer to bigint in the employee table, we can use the following:
ALTER TABLE employee CHANGE salary salary BIGINT;
RLIKE: Its full form is Right-Like and it is a special function in Hive. It helps examine two substrings, i.e., if the substring of A matches with B, then it evaluates to true.
‘Intellipaat’ RLIKE ‘tell’ True
‘Intellipaat’ RLIKE ‘^I.*’ True (this is a regular expression)
Learn more about Apache Hive from this detailed blog post now!
Following are the components of a Hive Query Processor:
Buckets in Hive are used in segregating Hive table data into multiple files or directories. They are used for efficient querying.
By using the below commands, we can access subdirectories recursively in Hive:
hive> Set mapred.input.dir.recursive=true;
hive> Set hive.mapred.supports.subdirectories=true;
Hive tables can be pointed to the higher level directory, and this is suitable for the directory structure like:
Imagine that header records in a table are as follows:
Suppose, we do not want to include the above three lines of headers in our Hive query. To skip the header lines from our table in Hive, we will set a table property.
CREATE EXTERNAL TABLE employee (
ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘ ‘ STORED AS TEXTFILE
The maximum size of a string data type supported by Hive is 2 GB. Hive supports the text file format by default, and it also supports the binary format sequence files, ORC files, Avro data files, and Parquet files.
Learn more about Hadoop from this Hadoop Training in New York to get ahead in your career!
We are using a precedence hierarchy for setting properties:
The hive.fetch.task.conversion property of Hive lowers the latency of MapReduce overhead, and in effect when executing queries such as SELECT, FILTER, LIMIT, etc. it skips the MapReduce function.
If you have any doubts or queries related to Hive, get them clarified from Hadoop experts on our Hive Community!
We can store Hive data in a highly efficient manner in an Optimized Row Columnar (ORC) file format. It can simplify many Hive file format limitations. We can improve the performance by using ORC files while reading, writing, and processing data.
CREATE TABLE orc_table (
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ‘\:’
LINES TERMINATED BY ‘\n’
STORES AS ORC;
Need a reason to learn Apache Hadoop and Hive? Well, go through this blog post to find out Why Hadoop is the new black?
ObjectInspector helps analyze the internal structure of a row object and the individual structure of columns in Hive. It also provides a uniform way to access complex objects that can be stored in multiple formats in the memory.
ObjectInspector tells the structure of the object and also the ways to access the internal fields inside the object.
A local metastore is created when we run Hive in an embedded mode. Before creating, it checks whether the metastore exists or not, and this metastore property is defined in the configuration file, hive-site.xml. The property is:
with the default value:
Therefore, we have to change the behavior of the location to an absolute path so that from that location the metastore can be used.
Interested in learning Hadoop? Check out the Hadoop Training in Sydney!
Hive tables can be pointed to the higher level directory, and this is suitable for the directory structure:
Hadoop Developers consider an array as their input and convert it into a separate table row. To convert complicated data types into desired table formats, Hive uses Explode.
Learn end-to-end Hadoop concepts through the Hadoop Course in Hyderabad to take your career to a whole new level!
Mostly, end-users prefer writing a Deserializer instead of using SerDe as they want to read their own data format instead of writing to it, e.g., RegexDeserializer deserializes data with the help of the configuration parameter ‘regex’ and with a list of column names.
If our SerDe supports DDL (i.e., SerDe with parameterized columns and column types), we will probably implement a protocol based on DynamicSerDe, instead of writing a SerDe. This is because the framework passes DDL to SerDe through the ‘Thrift DDL’ format and it’s totally unnecessary to write a “Thrift DDL” parser.
Are you interested in learning Hadoop from experts? Enroll in our Hadoop Course in Bangalore now!
The timestamp data type stores date in the java.sql.timestamp format.
Three collection data types in Hive are:
Yes, we can run UNIX shell commands from Hive using an ‘!‘ mark before the command. For example, !pwd at Hive prompt will display the current directory. We can execute Hive queries from the script files using the source command.
Hive> source /path/to/file/file_with_query.hql
Your email address will not be published. Required fields are marked *
Solve : * 28 + 3 =