cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

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();
1 ACCEPTED SOLUTION

Accepted Solutions

daniel_sahal
Esteemed Contributor

@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

1 REPLY 1

daniel_sahal
Esteemed Contributor

@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.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group