title: Spark - IllegalArgumentException in KMeans.train
body: <p>I am running into an exception while inside <code>KMeans.train()</code> like below:</p>
  
  <pre><code>java.lang.IllegalArgumentException: requirement failed
    at scala.Predef$.require(Predef.scala:212)
    at org.apache.spark.mllib.util.MLUtils$.fastSquaredDistance(MLUtils.scala:487)
    at org.apache.spark.mllib.clustering.KMeans$.fastSquaredDistance(KMeans.scala:589)
    at org.apache.spark.mllib.clustering.KMeans$$anonfun$runAlgorithm$3.apply(KMeans.scala:304)
    at org.apache.spark.mllib.clustering.KMeans$$anonfun$runAlgorithm$3.apply(KMeans.scala:301)
    at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:99)
    at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:99)
    at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:230)
    at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)
    at scala.collection.mutable.HashMap.foreach(HashMap.scala:99)
    at org.apache.spark.mllib.clustering.KMeans.runAlgorithm(KMeans.scala:301)
    at org.apache.spark.mllib.clustering.KMeans.run(KMeans.scala:227)
    at org.apache.spark.mllib.clustering.KMeans.run(KMeans.scala:209)
    at org.apache.spark.mllib.clustering.KMeans$.train(KMeans.scala:530)
  </code></pre>
  
  <p>This doesn't give me any clue on where to start debugging.<br>
  I found an old <a href="https://stackoverflow.com/questions/42678366/spark-ml-kmeans-give-org-apache-spark-sparkexception-failed-to-execute-user-d">post</a> but that issue was in <code>KMeans.predict()</code> whereas this is happening in the training phase itself.</p>