title: How to update or refresh ddl in Spark automatically from MySQL
body: <p>I'm using spark as datalake, the data source are tables from MySQL.</p>
  <p>Let's say there is a table in MySql.
  name and lastname are int data types</p>
  <p><a href="https://i.stack.imgur.com/kBexQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kBexQ.png" alt="enter image description here" /></a></p>
  <p>Then in Spark-sql</p>
  <pre><code>CREATE TABLE IF NOT EXISTS super_hero
  USING org.apache.spark.sql.jdbc
  OPTIONS (
    url &quot;jdbc:mysql://XXX.XXX.YYYY.YYYY:3306/test?useSSL=FALSE&amp;nullCatalogMeansCurrent=true&amp;zeroDateTimeBehavior=convertToNull&quot;,
    driver &quot;com.mysql.cj.jdbc.Driver&quot;,
    dbtable &quot;test.super_hero&quot;,
    user &quot;USER&quot;,
    password &quot;PASSWORD&quot;
  );
  </code></pre>
  <p>It works fine in spark-sql I ran:</p>
  <pre><code>    spark-sql&gt; select * from super_hero;
  1       0       0        superX        111-111
  </code></pre>
  <p>Then if I change the data types in MySql and then I re-ran the same command in Spark-sql</p>
  <pre><code>spark-sql&gt; select * from super_hero;
  22/07/25 22:57:05 ERROR Executor: Exception in task 0.0 in stage 4.0 (TID 4)
  java.sql.SQLDataException: Cannot determine value type from string 'Luis'
          at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:114)
  ...
  Caused by: com.mysql.cj.exceptions.DataConversionException: Cannot determine value type from string 'Luis'
          at com.mysql.cj.result.AbstractNumericValueFactory.createFromBytes(AbstractNumericValueFactory.java:65)
  </code></pre>
  <p>Is there any configuration to create a table in spark-sql to automictically get/refresh the latest DDL and data from MySQL?</p>
  <p>So far I have drop the table in spark-sql and recreate the table to get the latest ddl and data (in case of new columns).</p>