title: Hadoop's Hive/Pig, HDFS and MapReduce relationship
body: <p>My <em>understanding</em> of <a href="https://hive.apache.org/" rel="nofollow noreferrer">Apache Hive</a> is that its a SQL-like tooling layer for querying Hadoop clusters. My <em>understanding</em> of <a href="https://pig.apache.org/" rel="nofollow noreferrer">Apache Pig</a> is that its a procedural language for querying Hadoop clusters. So, if my understanding is correct, Hive and Pig <em>seem</em> like two different ways of solving the same problem.</p>
  
  <p>My problem, however, is that I don't understand the problem they are both solving in the first place!</p>
  
  <p>Say we have a DB (relational, NoSQL, doesn't matter) that feeds data into HDFS so that a particular MapReduce job can be run against that input data:</p>
  
  <p><img src="https://i.stack.imgur.com/1wmGF.png" alt="enter image description here"></p>
  
  <p>I'm confused as to which system Hive/Pig are querying! Are they querying the database? Are they querying the raw input data stored in the DataNodes on HDFS? Are they running little ad hoc, on-the-fly MR jobs and reporting their results/outputs?</p>
  
  <p>What is the relationship between these query tools, the MR job input data stored on HDFS, and the MR job itself?</p>