<?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>topic Re: Inconsistent behaviour in group by and order by in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/inconsistent-behaviour-in-group-by-and-order-by/m-p/96245#M39246</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This is not an issue, pls understand &lt;A href="https://www.geeksforgeeks.org/order-of-execution-of-sql-queries/" target="_self"&gt;order of execution of SQL queries&lt;/A&gt;. "Order by" clause will always refer to columns selected / displayed (as you are referring as id everywhere I guess there is a confusion).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SathyaSDE_0-1729949420766.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/12314i106F3E502F6CABB4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SathyaSDE_0-1729949420766.png" alt="SathyaSDE_0-1729949420766.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SathyaSDE_1-1729949460154.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/12315i92951E03DC22ABA6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SathyaSDE_1-1729949460154.png" alt="SathyaSDE_1-1729949460154.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ambiguous column name exception occurs when you refer same column names from two tables without aliasing it differently.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I hope it helps!!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 26 Oct 2024 13:32:11 GMT</pubDate>
    <dc:creator>SathyaSDE</dc:creator>
    <dc:date>2024-10-26T13:32:11Z</dc:date>
    <item>
      <title>Inconsistent behaviour in group by and order by</title>
      <link>https://community.databricks.com/t5/data-engineering/inconsistent-behaviour-in-group-by-and-order-by/m-p/96229#M39240</link>
      <description>&lt;P&gt;Consider this minimal example:&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;with&lt;/SPAN&gt;&lt;SPAN&gt; t &lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;select&lt;/SPAN&gt;&lt;SPAN&gt; explode(&lt;/SPAN&gt;&lt;SPAN&gt;sequence&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;10&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;)) &lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt; &lt;SPAN&gt;id&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;select&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;id&lt;/SPAN&gt;&lt;SPAN&gt;%&lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt; &lt;SPAN&gt;id&lt;/SPAN&gt; &lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; t&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;group by&lt;/SPAN&gt; &lt;SPAN&gt;id&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;order by&lt;/SPAN&gt; &lt;SPAN&gt;id&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;I would expect an ambiguous column name exception, since the grouping and sorting could apply to 2 different `id` columns. Instead the grouping is applied to t.id and the order is applied to (t.id%2).&lt;/P&gt;&lt;P&gt;Is there a setting we can apply to trigger an error when there is ambiguity? Can this be escalated?&lt;/P&gt;</description>
      <pubDate>Sat, 26 Oct 2024 10:27:31 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/inconsistent-behaviour-in-group-by-and-order-by/m-p/96229#M39240</guid>
      <dc:creator>sebasv</dc:creator>
      <dc:date>2024-10-26T10:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistent behaviour in group by and order by</title>
      <link>https://community.databricks.com/t5/data-engineering/inconsistent-behaviour-in-group-by-and-order-by/m-p/96236#M39244</link>
      <description>&lt;P&gt;Create a Spark issue&lt;/P&gt;
&lt;P&gt;&lt;A href="https://issues.apache.org/jira/projects/SPARK/issues/SPARK-48139?filter=allopenissues" target="_blank"&gt;https://issues.apache.org/jira/projects/SPARK/issues/SPARK-48139?filter=allopenissues&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Oct 2024 12:58:15 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/inconsistent-behaviour-in-group-by-and-order-by/m-p/96236#M39244</guid>
      <dc:creator>gchandra</dc:creator>
      <dc:date>2024-10-26T12:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistent behaviour in group by and order by</title>
      <link>https://community.databricks.com/t5/data-engineering/inconsistent-behaviour-in-group-by-and-order-by/m-p/96245#M39246</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This is not an issue, pls understand &lt;A href="https://www.geeksforgeeks.org/order-of-execution-of-sql-queries/" target="_self"&gt;order of execution of SQL queries&lt;/A&gt;. "Order by" clause will always refer to columns selected / displayed (as you are referring as id everywhere I guess there is a confusion).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SathyaSDE_0-1729949420766.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/12314i106F3E502F6CABB4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SathyaSDE_0-1729949420766.png" alt="SathyaSDE_0-1729949420766.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SathyaSDE_1-1729949460154.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/12315i92951E03DC22ABA6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SathyaSDE_1-1729949460154.png" alt="SathyaSDE_1-1729949460154.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ambiguous column name exception occurs when you refer same column names from two tables without aliasing it differently.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I hope it helps!!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Oct 2024 13:32:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/inconsistent-behaviour-in-group-by-and-order-by/m-p/96245#M39246</guid>
      <dc:creator>SathyaSDE</dc:creator>
      <dc:date>2024-10-26T13:32:11Z</dc:date>
    </item>
  </channel>
</rss>

