title: How effectively select data between 2 dates partitioned by year month day in presto?
body: <p>There is a table with <code>y</code> (year), <code>m</code> month, <code>d</code> (day) column. How to select query between 2 date? Like:</p>
  <pre><code>select * from my_table where y m d between '2018-12-01' and '2021-01-01'
  </code></pre>
  <p>There are 2 problems here:</p>
  <ol>
  <li>Using something the like <code>y &gt;= '2018' AND m &gt;= '12' AND d &gt;= '01' AND y &lt;= '2021' AND m &lt;= '01' AND d &lt;= '01'</code> lead to <code>m</code> must be more than <code>12</code> so no other month selected</li>
  <li>Using date functions <code>date (date_parse(y || m || d, '%Y%m%d')) between  date (date_parse('20181201', '%Y%m%d'))  and date (date_parse('20210101', '%Y%m%d'))</code> - leads to <code>HIVE_EXCEEDED_PARTITION_LIMIT</code>. It looks like <code>between date</code> generates partitions for every second (millisecond?)</li>
  </ol>
  <p>So how select with <code>between</code> date condition and do this effectively?</p>
  <p><strong>Note</strong></p>
  <p>I have added tag spark as well because presto run on top of spark - so problem should be general.</p>