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:ย 

Error when running OPTIMIZE on a Delta table with generated columns

620139
New Contributor II

I am seeing an error when running OPTIMIZE on a Delta table with generated columns:

com.databricks.sql.transaction.tahoe.schema.DeltaInvariantViolationException: CHECK constraint Generated Column (created <=> now()) violated by row with values:

 - created : 1672360020111000

Using a cluster with runtime 11.3 LTS (includes Apache Spark 3.3.0, Scala 2.12)

Any ideas how I can successfully OPTIMIZE this table?

3 REPLIES 3

Ajay-Pandey
Esteemed Contributor III

Have you applied any constraints on your table?

As it's giving errors for constraint 

Ajay Kumar Pandey

620139
New Contributor II

It appears the constraint is related to the generated column:

https://docs.databricks.com/delta/generated-columns.html

"For example, you can automatically generate a date column (for partitioning the table by date) from the timestamp column; any writes into the table need only specify the data for the timestamp column. However, if you explicitly provide values for them, the values must satisfy the constraint (<value> <=> <generation expression>) IS TRUE or the write will fail with an error."

Anonymous
Not applicable

Hi @Jeff Ericksonโ€‹ 

Thank you for your question! To assist you better, please take a moment to review the answer and let me know if it best fits your needs.

Please help us select the best solution by clicking on "Select As Best" if it does.

Your feedback will help us ensure that we are providing the best possible service to you.

Thank you!

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