title: Hive Query is going for full table scan when filtering on the partitions from the results of subquery/joins
body: <p>Why query1 runs for longer time compared to Query2.</p>
  <blockquote>
  <p>Hive Source Table Details</p>
  </blockquote>
  <pre><code>Columns - 166
  Partitions columns - 2 columns (all are int datatypes)
  Number of Partitions - 3211 partitions
  Total Records - 19374461064
  File Format - ORC
  </code></pre>
  <blockquote>
  <p>-- Query1</p>
  </blockquote>
  <pre><code>create table temp1 as 
  with temp_table1 as 
  (select col1 from temp_table where col1 between &lt;start_date&gt; and &lt;end_date&gt;), -- these query would get me the dates and there are derived dynamically in the script
  
  select f1.* from sourcetable f1 join temp_table1 f2 on f1.col1=f2.col1;
  </code></pre>
  <p>-- Above query runs for longer time, one of the steps takes ~1300 mappers and ~1000 reducers.
  -- Execution Time - ~120 Mins</p>
  <blockquote>
  <p>-- Query2</p>
  </blockquote>
  <p>-- if am passing the results of temp table1 in where clause as values, then query retreives results in under ~10mins.</p>
  <pre><code>select f1.* from source_table where f1.col1 in (value1, value2, value3, value3... value30);
  </code></pre>