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: 

How to Retrieve the spark.statistics.createdAt When Statistics Were Last Updated in Databricks?

Sainath368
New Contributor III

Hi everyone,

I regularly (once a week) run the analyze table compute statistics command on all my tables in Databricks to keep statistics up to date for query optimization.

In the Spark table UI catalog, I can see some statistics metadata like spark.statistics and spark.statistics.createdAt. However, when I query the table properties or use commands like describe table extended or check the table metadata programmatically, I can only retrieve statistics such as table size and row count — but not the spark.statistics.createdAt value indicating when the statistics were last computed.

Sainath368_0-1754309683688.png

I need to store this updated time in another table . Could anyone suggest a reliable method or the right command to retrieve the exact time when statistics were last updated or created for a table in Databricks/Spark?

Thanks in advance!


1 ACCEPTED SOLUTION

Accepted Solutions

Advika
Databricks Employee
Databricks Employee

Hello @Sainath368!

sql.statistics.createdAt reflects the epoch time when statistics were created. Unfortunately, there's no direct command available to check when the statistics were last updated.

As a workaround, you can manually set the current timestamp as a custom table property right after running the ANALYZE command.

View solution in original post

1 REPLY 1

Advika
Databricks Employee
Databricks Employee

Hello @Sainath368!

sql.statistics.createdAt reflects the epoch time when statistics were created. Unfortunately, there's no direct command available to check when the statistics were last updated.

As a workaround, you can manually set the current timestamp as a custom table property right after running the ANALYZE command.

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now