<?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 Databricks Notebook error : Analysis Exception with multiple datasets in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/databricks-notebook-error-analysis-exception-with-multiple/m-p/3900#M780</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am  getting below error when trying to execute the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AnalysisException:  Column Is There a PO#17748 are ambiguous. It's probably because you joined several Datasets together, and some of these Datasets are the same. This column points to one of the Datasets but Spark is unable to figure out which one. Please alias the Datasets with different names via `Dataset.as` before joining them, and specify the column using qualified name, e.g. `df.as("a").join(df.as("b"), $"a.id" &amp;gt; $"b.id")`. You can also set spark.sql.analyzer.failAmbiguousSelfJoin to false to disable this check. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Below is the code :&lt;/B&gt;&lt;/P&gt;&lt;P&gt;reguhjoin = reguhjoin.join(bseg_4j_c2, reguhjoin.conc2 == bseg_4j_c2['Concatenate 2'], how='left').select(reguhjoin["*"], bseg_4j_c2["Is There a PO"])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the code is working fine in lower environment and when we try to migrate to PRD we are getting above error, Please suggest.&lt;/P&gt;</description>
    <pubDate>Mon, 29 May 2023 16:20:32 GMT</pubDate>
    <dc:creator>vijaykumarbotla</dc:creator>
    <dc:date>2023-05-29T16:20:32Z</dc:date>
    <item>
      <title>Databricks Notebook error : Analysis Exception with multiple datasets</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-notebook-error-analysis-exception-with-multiple/m-p/3900#M780</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am  getting below error when trying to execute the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AnalysisException:  Column Is There a PO#17748 are ambiguous. It's probably because you joined several Datasets together, and some of these Datasets are the same. This column points to one of the Datasets but Spark is unable to figure out which one. Please alias the Datasets with different names via `Dataset.as` before joining them, and specify the column using qualified name, e.g. `df.as("a").join(df.as("b"), $"a.id" &amp;gt; $"b.id")`. You can also set spark.sql.analyzer.failAmbiguousSelfJoin to false to disable this check. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Below is the code :&lt;/B&gt;&lt;/P&gt;&lt;P&gt;reguhjoin = reguhjoin.join(bseg_4j_c2, reguhjoin.conc2 == bseg_4j_c2['Concatenate 2'], how='left').select(reguhjoin["*"], bseg_4j_c2["Is There a PO"])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the code is working fine in lower environment and when we try to migrate to PRD we are getting above error, Please suggest.&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2023 16:20:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-notebook-error-analysis-exception-with-multiple/m-p/3900#M780</guid>
      <dc:creator>vijaykumarbotla</dc:creator>
      <dc:date>2023-05-29T16:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Databricks Notebook error : Analysis Exception with multiple datasets</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-notebook-error-analysis-exception-with-multiple/m-p/71955#M34447</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/67304"&gt;@vijaykumarbotla&lt;/a&gt;&amp;nbsp;, I hope you're doing well.&lt;/P&gt;
&lt;P&gt;This is probably because both DataFrames contain a column with the same name, and Spark is unable to determine which one you are referring to in the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="du-bois-dark-typography css-aqikf3"&gt;&lt;CODE&gt;select&lt;/CODE&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;statement.&lt;/P&gt;
&lt;DIV class="du-bois-dark-typography css-eyq5p0"&gt;To resolve this issue, you can use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="du-bois-dark-typography css-aqikf3"&gt;&lt;CODE&gt;alias&lt;/CODE&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;method to give each DataFrame a unique alias, and then use the qualified column name (i.e.,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="du-bois-dark-typography css-aqikf3"&gt;&lt;CODE&gt;aliasName.columnName&lt;/CODE&gt;&lt;/SPAN&gt;) in the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="du-bois-dark-typography css-aqikf3"&gt;&lt;CODE&gt;select&lt;/CODE&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;statement. Here's an example of how you can modify your code to fix the issue:&lt;/DIV&gt;
&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN&gt;reguhjoin &lt;/SPAN&gt;&lt;SPAN class="token"&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; reguhjoin&lt;/SPAN&gt;&lt;SPAN class="token"&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;alias&lt;/SPAN&gt;&lt;SPAN class="token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token"&gt;"reguhjoin"&lt;/SPAN&gt;&lt;SPAN class="token"&gt;)&lt;/SPAN&gt;
&lt;SPAN&gt;bseg_4j_c2 &lt;/SPAN&gt;&lt;SPAN class="token"&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; bseg_4j_c2&lt;/SPAN&gt;&lt;SPAN class="token"&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;alias&lt;/SPAN&gt;&lt;SPAN class="token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token"&gt;"bseg_4j_c2"&lt;/SPAN&gt;&lt;SPAN class="token"&gt;)&lt;/SPAN&gt;

&lt;SPAN&gt;reguhjoin_joined &lt;/SPAN&gt;&lt;SPAN class="token"&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; reguhjoin&lt;/SPAN&gt;&lt;SPAN class="token"&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;join&lt;/SPAN&gt;&lt;SPAN class="token"&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;bseg_4j_c2&lt;/SPAN&gt;&lt;SPAN class="token"&gt;,&lt;/SPAN&gt;&lt;SPAN&gt; reguhjoin&lt;/SPAN&gt;&lt;SPAN class="token"&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;conc2 &lt;/SPAN&gt;&lt;SPAN class="token"&gt;==&lt;/SPAN&gt;&lt;SPAN&gt; bseg_2&lt;/SPAN&gt;&lt;SPAN class="token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="token"&gt;'Concatenate 2'&lt;/SPAN&gt;&lt;SPAN class="token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token"&gt;,&lt;/SPAN&gt;&lt;SPAN&gt; how&lt;/SPAN&gt;&lt;SPAN class="token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token"&gt;'left'&lt;/SPAN&gt;&lt;SPAN class="token"&gt;)&lt;/SPAN&gt;
&lt;SPAN&gt;reguhjoin_joined_selected &lt;/SPAN&gt;&lt;SPAN class="token"&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; reguhjoin_joined&lt;/SPAN&gt;&lt;SPAN class="token"&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;select&lt;/SPAN&gt;&lt;SPAN class="token"&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;reguhjoin_joined&lt;/SPAN&gt;&lt;SPAN class="token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="token"&gt;"reguhjoin.*"&lt;/SPAN&gt;&lt;SPAN class="token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token"&gt;,&lt;/SPAN&gt;&lt;SPAN&gt; bseg_4j_c2&lt;/SPAN&gt;&lt;SPAN class="token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="token"&gt;"Is There a PO"&lt;/SPAN&gt;&lt;SPAN class="token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If possible please test the provided code, in case it doesn't work, please let me know the difference between the environments you are running this code.&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Lucas Rocha&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 21:00:28 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-notebook-error-analysis-exception-with-multiple/m-p/71955#M34447</guid>
      <dc:creator>lucasrocha</dc:creator>
      <dc:date>2024-06-06T21:00:28Z</dc:date>
    </item>
  </channel>
</rss>

