title: Power BI Athena Incremental Refresh
body: <p>I have been successfully using Power BI’s incremental refresh daily with a MySQL data source. However, I can't get this configured with AWS Athena, because seemingly the latter interprets the values in the required parameters <code>RangeStart</code> and <code>RangeEnd</code> as strings.  Since the data source is around 50 million rows I’d rather avoid querying this from scratch every day. </p>
  
  <p>In <a href="https://youtu.be/JsJWBr1_ktQ?t=153" rel="nofollow noreferrer">this video</a> from <em>Guy in a Cube</em>, you can clearly see that the query sent by Power BI to Azure has a <em>convert to datetime2</em> function - something like this is presumably missing for Athena/Presto, which needs the type constructor TIMESTAMP in order to do datetime comparisons (<a href="https://stackoverflow.com/a/38041684/3675679">https://stackoverflow.com/a/38041684/3675679</a>), and of course incremental refresh must be based on datetime fields.  I am using the datetime field <code>adv_date</code> for the incremental load. </p>
  
  <p>Here is what the M query looks like in Power Query Editor: </p>
  
  <pre><code>= Table.SelectRows(#"Removed Columns1", each [adv_date] &gt;= RangeStart and [adv_date] &lt; RangeEnd) 
  </code></pre>
  
  <p>And here is the resultant error message in Athena: </p>
  
  <pre><code>Your query has the following errors:SYNTAX_ERROR: line 1:1: Incorrect number of parameters: expected 2 but found 0 
  </code></pre>
  
  <p>Whilst this is how Athena interprets the query: </p>
  
  <pre class="lang-sql prettyprint-override"><code>    select "col1", "col2", "adv_date" 
      from "AwsDataCatalog"."test"."test_table" 
      where "adv_date" &gt;= ? and "adv_date" &lt; ?
  </code></pre>
  
  <p>I have contacted Power BI support without success.  Does anyone have a workaround for this by any chance?  Happy to provide more info if needed.</p>