title: SPARK read.jdbc & custom schema
body: <p>With spark.read.format ... once can add the custom schema non-programmatically, like so:</p>
  
  <pre><code>val df = sqlContext
  .read()
  .format("jdbc")
  .option("url", "jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&amp;characterEncoding=UTF-8&amp;autoReconnect=true")
  .option("user", "root")
  .option("password", "password")
  .option("dbtable", sql)
  .schema(customSchema)
  .load();
  </code></pre>
  
  <p>However, using spark.read.jdbc, I cannot seem to do the same or find the syntax to do the same as for the above. What am i missing or has this changed in SPARK 2.x? I read this in the manual: <strong><em>... Spark automatically reads the schema from the database table and maps its types back to Spark SQL types. ...</em></strong>  Presumably what I am trying to do is no longer possible as in the above example. </p>
  
  <pre><code>val dataframe_mysql = spark.read.jdbc(jdbcUrl, "(select k, v from sample) e ", connectionProperties)
  </code></pre>
  
  <p>I ended up trying this:</p>
  
  <pre><code>val dataframe_mysql = spark.read.schema(openPositionsSchema).jdbc(jdbcUrl, "(select k, v from sample) e ", connectionProperties)
  </code></pre>
  
  <p>and got this:</p>
  
  <pre><code>org.apache.spark.sql.AnalysisException: User specified schema not supported with `jdbc`;
  </code></pre>
  
  <p>Seems a retrograde step in a certain way.</p>