ArticleslgStudy

computer science

Apache Hive

Apache Hive is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Apache Hive rather than just read about it. In short: Apache Hive is a data warehouse software project. It is built on top of Apache Hadoop for providing data query and analysis.

Apache Hive — main illustration
Apache Hive — illustration

Key takeaways

  • Apache Hive belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Apache Hive to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Apache Hive from memory before moving on to harder problems.

Reference excerpt

Apache Hive is a data warehouse software project. It is built on top of Apache Hadoop for providing data query and analysis. Hive gives an SQL-like interface to query data stored in various databases and file systems that integrate with Hadoop. Traditional SQL queries must be implemented in the MapReduce Java API to execute SQL applications and queries over distributed data. Hive provides the necessary SQL abstraction to integrate SQL-like queries (HiveQL) into the underlying Java without the need to implement queries in the low-level Java API. Hive facilitates the integration of SQL-based querying languages with Hadoop, which is commonly used in data warehousing applications. While initially developed by Facebook, Apache Hive is used and developed by other companies such as Netflix and the Financial Industry Regulatory Authority (FINRA). Amazon maintains a software fork of Apache Hive included in Amazon Elastic MapReduce on Amazon Web Services.

Features Apache Hive supports the analysis of large datasets stored in Hadoop's HDFS and compatible file systems such as Amazon S3 filesystem and Alluxio. It provides a SQL-like query language called HiveQL with schema on read and transparently converts queries to MapReduce, Apache Tez and Spark jobs. All three execution engines can run in Hadoop's resource negotiator, YARN (Yet Another Resource Negotiator). To accelerate queries, it provided indexes, but this feature was removed in version 3.0 Other features of Hive include:

Different storage types such as plain text, RCFile, HBase, ORC, and others. Metadata storage in a relational database management system, significantly reduces the time to perform semantic checks during query execution. Operating on compressed data stored in the Hadoop ecosystem using algorithms including DEFLATE, BWT, Snappy, etc. Built-in user-defined functions (UDFs) to manipulate dates, strings, and other data-mining tools. Hive supports extending the UDF set to handle use cases not supported by built-in functions. SQL-like queries (HiveQL), which are implicitly converted into MapReduce or Tez, or Spark jobs. By default, Hive stores metadata in an embedded Apache Derby database, and other client/server databases like MySQL can optionally be used. The first four file formats supported in Hive were plain text, sequence file, optimized row columnar (ORC) format and RCFile. Apache Parquet can be read via plugin in versions later than 0.10 and natively starting at 0.13.

Architecture Major components of the Hive architecture include the metastore, driver, compiler, optimizer, executor, and user interfaces. The metastore stores metadata for each of the tables, such as their schema and location. It also includes partition metadata which helps the driver to track the progress of various data sets distributed over the cluster. The data is stored in a traditional RDBMS format. This metadata enables the driver to keep track of the data. A backup server regularly replicates the data to provide recovery in case of data loss. The driver acts like a controller which receives the HiveQL statements. It starts the execution of the statement by creating sessions and monitors the life cycle and progress of the execution. It stores the necessary metadata generated during the execution of a HiveQL statement. The driver also acts as a collection point of data or query results obtained after the Reduce operation. The compiler performs compilation of the HiveQL query, converting the query to an execution plan. This plan contains the tasks and steps needed to be performed by the Hadoop MapReduce to get the output as translated by the query. The compiler converts the query to an abstract syntax tree (AST). After checking for compatibility and compile time errors, it converts the AST to a directed acyclic graph (DAG). The DAG divides operators to MapReduce stages and tasks based on the input query and data. The optimizer performs various transformations on the execution plan to produce an optimized DAG. Transformations can be aggregated together, such as converting a pipeline of joins to a single join, for better performance. It can also split tasks, such as applying a transformation on data before a reduce operation, to provide better performance and scalability. The logic of transformation used for optimization can be modified or pipelined using another optimizer. An optimizer called YSmart is a part of Apache Hive. This correlated optimizer merges correlated MapReduce jobs into a single MapReduce job, significantly reducing the execution time. The executor executes the tasks after compilation and optimization. It interacts with the job tracker of Hadoop to schedule tasks to be run. It takes care of pipelining the tasks by making sure that a task with a dependency gets executed only if all other prerequisites have been completed. A command-line interface (CLI) provides a user interface for an external user to interact with Hive by submitting queries and instructions and monitoring the process status. The Thrift Server allows external clients to interact with Hive over a network, similar to the JDBC or ODBC protocols.

HiveQL While based on SQL, HiveQL does not strictly follow the full SQL-92 standard. HiveQL offers extensions not in SQL, including multi-table inserts, and creates tables as select. HiveQL lacked support for transactions and materialized views, and offered only limited subquery support. Support for insert, update, and delete with full ACID functionality was made available with release 0.14. Internally, a compiler translates HiveQL statements into a directed acyclic graph of MapReduce, Tez, or Spark jobs, which are submitted to Hadoop for execution.

Example The word count program counts the number of times each word occurs in the input. The word count can be written in HiveQL as:

A brief explanation of each of the statements is as follows:

Checks if table docs exists and drops it if it does. Creates a new table called docs with a single column of type STRING called line.

Loads the specified file or directory (In this case “input_file”) into the table. OVERWRITE specifies that the target table to which the data is being loaded into is to be re-written; Otherwise, the data would be appended.

… excerpt ends here. Continue reading the full article.

Illustrations

Apache Hive illustration

Worked examples

Example 1 — a first encounter with Apache Hive

Start with the simplest possible case. Write down what Apache Hive claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Apache Hive before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Apache Hive ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Apache Hive

In research
Apache Hive appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Apache Hive in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Apache Hive is common in secondary-school and first-year university syllabi. It links to neighbouring topics 2015 software, Apache Hadoop, Apache Software Foundation projects, so understanding it makes those chapters shorter.
In everyday life
Look for Apache Hive outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Apache Hive” →

How to study Apache Hive in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Apache Hive means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Apache Hive out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Apache Hive in simple terms?

Apache Hive is a data warehouse software project. It is built on top of Apache Hadoop for providing data query and analysis.

Why does Apache Hive matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Apache Hive?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Apache Hive.

Tags

  • 2015 software
  • Apache Hadoop
  • Apache Software Foundation projects
  • Cloud computing
  • Facebook software
  • Free software programmed in Java
  • Free system software
  • Software using the Apache license

Keep exploring