<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: How to ask hive query to fetch data for specific partition? in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/How-to-ask-hive-query-to-fetch-data-for-specific-partition/m-p/115207#M78001</link>
    <description>&lt;P&gt; &lt;A rel="user" href="https://community.cloudera.com/users/10447/manoj-dhake.html" nodeid="10447"&gt;@Manoj Dhake&lt;/A&gt;&lt;/P&gt;&lt;H3&gt;Partition Based Queries&lt;/H3&gt;&lt;P&gt;In general, a SELECT query scans the entire table (other than for &lt;A href="https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Sampling"&gt;sampling&lt;/A&gt;). If a table created using the &lt;A href="https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTable"&gt;PARTITIONED BY&lt;/A&gt; clause, a query can do &lt;STRONG&gt;partition pruning&lt;/STRONG&gt; and scan only a fraction of the table relevant to the partitions specified by the query. Hive currently does partition pruning if the partition predicates are specified in the WHERE clause or the ON clause in a JOIN. For example, if table page_views is partitioned on column date, the following query retrieves rows for just days between 2008-03-01 and 2008-03-31.&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;CODE&gt;SELECT page_views.*&lt;/CODE&gt;
&lt;CODE&gt;FROM page_views&lt;/CODE&gt;
&lt;CODE&gt;WHERE page_views.date &amp;gt;= &lt;/CODE&gt;&lt;CODE&gt;'2008-03-01'&lt;/CODE&gt; &lt;CODE&gt;AND page_views.date &amp;lt;= &lt;/CODE&gt;&lt;CODE&gt;'2008-03-31'&lt;/CODE&gt;
&lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;If a table page_views is joined with another table dim_users, you can specify a range of partitions in the ON clause as follows:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;CODE&gt;SELECT page_views.*&lt;/CODE&gt;
&lt;CODE&gt;FROM page_views JOIN dim_users&lt;/CODE&gt;
&lt;CODE&gt;ON (page_views.user_id = dim_users.id AND page_views.date &amp;gt;= &lt;/CODE&gt;&lt;CODE&gt;'2008-03-01'&lt;/CODE&gt; &lt;CODE&gt;AND page_views.date &amp;lt;= &lt;/CODE&gt;&lt;CODE&gt;'2008-03-31'&lt;/CODE&gt;&lt;CODE&gt;)&lt;/CODE&gt;
&lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;UL&gt;
&lt;LI&gt;See also &lt;A href="https://cwiki.apache.org/confluence/display/Hive/LanguageManual+GroupBy"&gt;Group By&lt;/A&gt;.&lt;/LI&gt;&lt;LI&gt;See also &lt;A href="https://cwiki.apache.org/confluence/display/Hive/LanguageManual+SortBy"&gt;Sort By / Cluster By / Distribute By / Order By&lt;/A&gt;.&lt;/LI&gt;&lt;/UL&gt;</description>
    <pubDate>Thu, 02 Jun 2016 00:26:58 GMT</pubDate>
    <dc:creator>sunile_manjee</dc:creator>
    <dc:date>2016-06-02T00:26:58Z</dc:date>
  </channel>
</rss>

