title: QUERY_HAS_TOO_MANY_STAGES error in AWS Athena
body: <p>I was running a long query in AWS Athena when I got this error:</p>
  <blockquote>
  <p>QUERY_HAS_TOO_MANY_STAGES: Number of stages in the query (1725) exceeds the allowed maximum (1500). If the query contains multiple DISTINCTs, please set the 'use_mark_distinct' session property to false. If the query contains multiple CTEs that are referenced more than once, please create temporary table(s) for one or more of the CTEs.</p>
  </blockquote>
  <p>I went through this presto <a href="https://trino.io/docs/current/admin/properties-query-management.html#query-max-stage-count" rel="nofollow noreferrer">documentation</a> but it wasn't much helpful.
  I also tried to change the <code>query.stage-count-warning-threshold</code> as mentioned <a href="https://prestodb.io/docs/current/release/release-0.217.html" rel="nofollow noreferrer">here</a>, but seems like boto3 doesn't allow any means to change per query configuration.</p>
  <p>Is there any way to increase the number of stages without any quota increase ?</p>