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 II

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.

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!