Problem
You want to determine the last modified timestamp for a Delta table. You rely on the last_altered
column in the system.information_schema.tables
, but notice this column doesn't always reflect the correct timestamp when the table experiences updates or inserts.
Cause
The last_altered
column in the system.information_schema.tables
displays the timestamp when the table's structure was last modified (such as changes to the table schema, metadata, or table properties).
It does not track data modifications such as inserts, updates, or deletes, so does not show a timestamp for the table’s data changes.
Solution
To accurately track when a Delta table’s structure or data was last modified, use the lastModified column returned by the DESCRIBE DETAIL
command.
%sql
DESCRIBE DETAIL <your-catalog>.<your-schema>.<your-table-name>;
DESCRIBE DETAIL
returns comprehensive table information, including the timestamp that reflects the most recent modification to the table's data or structure.