Hi All,
I have a databricks table with the below DDL:
CREATE TABLE default.Test (
ID BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
StopFromDateTime TIMESTAMP,
StopToDateTime TIMESTAMP,
User STRING)
USING delta
TBLPROPERTIES (
'delta.autoOptimize.autoCompact' = 'true',
'delta.autoOptimize.optimizeWrite' = 'true',
'delta.columnMapping.mode' = 'name',
'delta.minReaderVersion' = '2',
'delta.minWriterVersion' = '6')
I have inserted 3 rows of data into the table and the table with the data looks like below:
ID StartDateTime StopDateTime User
1 2020-01-01 2020-01-02 Josh
2 2021-01-01 2021-01-02 Alex
3 2022-01-01 2022-01-02 Ross
When i look at the history of the table it has 4 versions, 1(Create),2,3&4(Insert). I had to delete the records for ID 2&3 so instead of deleting it i did a restore of the table to version 2 which has the first insert so my table now has the data like this
ID StartDateTime StopDateTime User
1 2020-01-01 2020-01-02 Josh
I have inserted another record into the table now for and after inserting the new record my table looks like this:
ID StartDateTime StopDateTime User
1 2020-01-01 2020-01-02 Josh
4 2023-01-01 2023-01-02 Steve
I was hoping the new ID would be 2 as i restored it to a version before ID 2&3 are inserted however its getting 4.
Can someone provide any inputs on how can i reset the identity on this table?