title: How to convert correlated sub query to pyspark code
body: <p>I am trying to convert correlated subquery in to pyspark code and i am getting below error.</p>
  <blockquote>
  <p>Attribute(s) with the same name appear in the operation:</p>
  </blockquote>
  <p>Sample sql query:</p>
  <pre class="lang-sql prettyprint-override"><code>select(few columns)
  from table0 spw1 
  JOIN table1 spw2
         ON ( spw2.date_key=(SELECT MAX(date_key)
                              FROM table2 spw3
                              WHERE spw3.name =spw1.name
                              AND spw3.id = spw1.id
                              AND spw3.v_key=spw1.v_key
                              AND spw3.start_date &lt; spw1.prev_start_date)
  </code></pre>