title: Duplicate columns in Spark Dataframe
body: <p>I have a 10GB csv file in hadoop cluster with duplicate columns. I try to analyse it in SparkR so I use <code>spark-csv</code> package to parse it as <code>DataFrame</code>:</p>
  
  <pre><code>  df &lt;- read.df(
      sqlContext,
      FILE_PATH,
      source = "com.databricks.spark.csv",
      header = "true",
      mode = "DROPMALFORMED"
    )
  </code></pre>
  
  <p>But since df have duplicate <code>Email</code> columns, if I want to select this column, it would error out:</p>
  
  <pre><code>select(df, 'Email')
  
  15/11/19 15:41:58 ERROR RBackendHandler: select on 1422 failed
  Error in invokeJava(isStatic = FALSE, objId$id, methodName, ...) : 
    org.apache.spark.sql.AnalysisException: Reference 'Email' is ambiguous, could be: Email#350, Email#361.;
      at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.resolve(LogicalPlan.scala:278)
  ...
  </code></pre>
  
  <p>I want to keep the first occurrence of <code>Email</code> column and delete the latter, how can I do that?</p>