title: Spark: Record count mismatch
body: <p>I am quite confused because I am facing a weird situation.
  My spark application reads data from an Oracle database and load it into a dataframe using this instruction:</p>
  
  <pre><code>  private val df = spark.read.jdbc(
      url = [the jdbc url],
      table="(" + [the query] + ") qry",
      properties= [the oracle driver]
    )
  </code></pre>
  
  <p>Then, I save in a variable the number of records in this dataframe:</p>
  
  <pre><code>val records = df.count()
  </code></pre>
  
  <p>The I create a hive table ([my table]) with the dataframe schema, and I dump the content of the dataframe on it:</p>
  
  <pre><code>df.write
    .mode(SaveMode.Append)
    .insertInto([my hive db].[my table])
  </code></pre>
  
  <p>Well, here is where I am lost; When I perform a <code>select count(*)</code> to the hive table where the dataframe is being loaded, "sometimes" there are a few records more in hive than in the <code>records</code> variable.</p>
  
  <p>Can you think on what could be the source of this mismatch??</p>
  
  <hr>
  
  <p>*Related to the <em>possible duplicate</em>, my question is different. I am not counting my dataframe many times with different values. I count the records on my dataframe once. I dump the dataframe into hive, and I count the records in the hive table, and sometimes there are more in hive than in my count.*</p>
  
  <hr>
  
  <p>Thank you very much in advance.</p>