<p dir="auto">If the metric name/expression is the same as the SORT BY metric, the SORT BY metric is re-added to the SELECT clause (necessary for sorting) which results in selecting the expression twice which then introduces ambiguity resulting in the query engine returning an error.</p>
<h3 dir="auto">Expected results</h3>
<p dir="auto">The SORT BY metric should not be re-added to the SELECT clause.</p>
<h3 dir="auto">Actual results</h3>
<p dir="auto">Depending on the engine an error may be thrown, i.e., for Presto:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="line 65:10: Column 'sum(total)' is ambiguous"><pre class="notranslate"><code class="notranslate">line 65:10: Column 'sum(total)' is ambiguous
</code></pre></div>
<h4 dir="auto">Screenshots</h4>
<p dir="auto">If applicable, add screenshots to help explain your problem.</p>
<h4 dir="auto">How to reproduce the bug</h4>
<ol dir="auto">
<li>Go to explorer.</li>
<li>Add a metric to both the <code class="notranslate">METRICS</code> section (chart dependent) and <code class="notranslate">SORT BY</code>.</li>
<li>Select a <code class="notranslate">GROUP BY</code>.</li>
<li>Click <code class="notranslate">RUN</code>.</li>
<li>Possibly see the error and notice that the metric is duplicated in the SQL, i.e.,</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="SELECT 
    ...
    sum(&quot;total&quot;) AS &quot;SUM(total)&quot;,
    sum(&quot;total&quot;) AS &quot;SUM(total)&quot;"><pre class="notranslate"><code class="notranslate">SELECT 
    ...
    sum("total") AS "SUM(total)",
    sum("total") AS "SUM(total)"
</code></pre></div>
<h3 dir="auto">Environment</h3>
<p dir="auto">(please complete the following information):</p>
<ul dir="auto">
<li>superset version: <code class="notranslate">master</code></li>
<li>python version: <code class="notranslate">3.7</code></li>
<li>node.js version: <code class="notranslate">node -v</code></li>
</ul>
<h3 dir="auto">Checklist</h3>
<p dir="auto">Make sure to follow these steps before submitting your issue - thank you!</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the superset logs for python stacktraces and included it here as text if there are any.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have reproduced the issue with at least the latest released version of superset.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the issue tracker for the same issue and I haven't found one similar.</li>
</ul>
<p dir="auto">The workflow docker-ephemeral-env.yml is referencing action aws-actions/amazon-ecr-login using references v1. However this reference is missing the commit <a href="https://github.com/aws-actions/amazon-ecr-login/commits/57206dc28c379a6eebdce44c592109d2e97e031d">57206dc28c379a6eebdce44c592109d2e97e031d</a> which may contain fix to the some vulnerability.<br>
The vulnerability fix that is missing by actions version could be related to:<br>
(1) CVE fix<br>
(2) upgrade of vulnerable dependency<br>
(3) fix to secret leak and others.<br>
Please consider to update the reference to the action.</p>