cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

How to find the identity column seed value?

lizou
Contributor II

How to find the identity column seed value? A seed value is required when we need specifically like start generating new values from a number (most likely we need to keep the original key values when data is reloaded from another source, and any new data need starts from the current max value +1)

new from runtime 10.4

GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ ( [ START WITH start ] [ INCREMENT BY step ] ) ]

I have done searching on documents, and there is no result.

in sql server, the equivalent statement is

-- check current identity seed value

DBCC CHECKIDENT ('dbo.table_with_identity_col');

1 ACCEPTED SOLUTION

Accepted Solutions

Hubert-Dudek
Esteemed Contributor III

When you go to source delta files on the dbfs, you can see that in JSON and CRC, there is field delta.identity.highWaterMark, which contains max identity value. I couldn't find any way to get that value in SQL. Of course, you can aggregate MAX. I asked the Delta team if there a way to get highWaterMark

View solution in original post

2 REPLIES 2

Hubert-Dudek
Esteemed Contributor III

When you go to source delta files on the dbfs, you can see that in JSON and CRC, there is field delta.identity.highWaterMark, which contains max identity value. I couldn't find any way to get that value in SQL. Of course, you can aggregate MAX. I asked the Delta team if there a way to get highWaterMark

lizou
Contributor II

found it, thanks!

of course, it will be nice to have a sql function available to query the value.

example

\"delta.identity.start\":984888,\"delta.identity.highWaterMark\":1004409,\"comment\":\"identity\",\"delta.identity.step\":1}

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.