Scala how to write data to sqlmi table that has identity col, auto-initialized col DATETIME DEFAULT

JamesY
New Contributor III

Scala, I am trying to write dataframe to sqlmi table, it works for all other table when dataframe columns matches table columns, and I created a new table with the identity and auto-initialized column, from what I understand, by default, I don't need to add value for these two column, and thus my dataframe doesn't include the two columns, but I got an error of:

Spark Dataframe and SQL Server table have differing numbers of columns
How to write data correctly to this type of table?
df.write
      .format("jdbc")
      .mode("append")
      .option("url", ...)
      .option("dbtable", ...)
      .save();

daniel_sahal
Databricks MVP

@JamesY 
Try adding the missing columns as a dummy columns. I've seen this issue happening some time ago - it looks like it's still not fixed.

View solution in original post