title: Error while creating dataset in Java spark-3.x using Encoders bean with Dense Vector. (Issue arises when updating spark from 2.4 to 3.x)
body: <p>I encountered a compatibility issue while upgrading spark from 2.4 to 3.x (also scala is upgraded from 2.11 to 2.12). Just checking if someone else has encountered a similar issue before or any advice</p>
  <p>This java code below used to work with spark 2.4 but when migrated to 3.x it gives the error (mentioned below)
  I have done my own research but couldn't find a solution or any related information.</p>
  <pre><code>public void test() {
      final SparkSession spark = SparkSession.builder()
              .appName(&quot;Test&quot;)
              .getOrCreate();
  
      DenseClass denseFactor1 = new DenseClass( new DenseVector( new double[]{0.13, 0.24}));
      DenseClass denseFactor2 = new DenseClass( new DenseVector( new double[]{0.24, 0.32}));
  
      final List&lt;DenseClass&gt; inputsNew = Arrays.asList(denseFactor1, denseFactor2);
  
      final Dataset&lt;DenseClass&gt; denseVectorDf = spark.createDataset(inputsNew, Encoders.bean(DenseClass.class));
      denseVectorDf.printSchema();
  }
  
  
  public static class DenseClass implements Serializable {
      private org.apache.spark.ml.linalg.DenseVector denseVector;
    }
  </code></pre>
  <p>The error occurs while creating the dataset <strong>denseVectorDf</strong> .</p>
  <p>Error</p>
  <pre><code>org.apache.spark.sql.AnalysisException: Cannot up cast `denseVector` from struct&lt;&gt; to struct&lt;type:tinyint,size:int,indices:array&lt;int&gt;,values:array&lt;double&gt;&gt;.
  The type path of the target object is:
  - field (class: &quot;org.apache.spark.ml.linalg.DenseVector&quot;, name: &quot;denseVector&quot;)
  You can either add an explicit cast to the input data or choose a higher precision type of the field in the target object
  </code></pre>
  <p>I have tried to use <em>double</em> instead of dense vector and it works just fine, but fails on using the dense vector with encoders bean.</p>