title: On Spark DataFrame save to JSON and load back, schema column sequence changes
body: <p>I am using spark DataFrames and trying to do de-duplication across to DataFrames of same schema.</p>
  
  <p>schema for before saving DataFrame to JSON is like:</p>
  
  <pre><code>root
   |-- startTime: long (nullable = false)
   |-- name: string (nullable = true)
  </code></pre>
  
  <p>Schema of DataFrame after loading from JSON file is like:</p>
  
  <pre><code>root
   |-- name: string (nullable = true)
   |-- startTime: long (nullable = false)
  </code></pre>
  
  <p>I save to JSON as:</p>
  
  <pre><code>newDF.write.json(filePath)
  </code></pre>
  
  <p>and read back as:</p>
  
  <pre><code>existingDF = sqlContext.read.json(filePath)
  </code></pre>
  
  <p>After doing unionAll </p>
  
  <pre><code>existingDF.unionAll(newDF).distinct()
  </code></pre>
  
  <p>or except</p>
  
  <pre><code>newDF.except(existingDF)
  </code></pre>
  
  <p>The de-duplication fails because of schema change.</p>
  
  <p>Can I avoid this schema conversion?
  Is there a way to conserve (or enforce) schema sequence while saving to and loading back from JSON file?</p>