2 weeks ago
The When to replace a table documentation states that using CREATE OR REPLACE TABLE should preserve the table’s identity:
Table contents are replaced, but the table identity is maintained.
However, in my recent test the table ID changed after running this command. Is this expected behavior?
For example, the transaction log shows:
Version 0:
{"metaData":{"id":"6a085d18-3aef-4c4c-890b-fb4a6f9d6888", ...}}
Version 2: (post command)
{"metaData":{"id":"e3f5d990-2c03-483e-8cd3-a772d5d87e93", ...}}
Should CREATE OR REPLACE TABLE ever generate a new table ID, or is this a bug?
2 weeks ago
Yes that's correct. The table identity is preserved in case of delta tables. If the table is non delta it will not be preserved.
Can you also confirm if the table you are recreating have schema changes. Because sometimes CREATE OR REPLACE TABLE with change in column definitions, table properties or format may be treated as drop and recreate operation internally which might result in id lost.
2 weeks ago - last edited 2 weeks ago
HI @nayan_wylde , @shanisolomonron
I don't think it works in the way you've described. We can easily check this. Each time I execute following code I get new id:
%sql
CREATE OR REPLACE TABLE databricks_demo_ws.default.my_table (
id int,
name string
)
So, first time I've exectued above code I got id: f2a57c4-152b-46c4-9dd5-b1e945846d71
Then I execute above code second time. As you can see, no major schema changes occured but still I got completly new id: 641cacab-7175-4f44-98cc-fad9ba8aa66e
I think what they refer in docs as table identity is more related to catalog / metadata identity (not necessarily the same as the internal delta log id). Because all other things mentioned in documentation hold:
2 weeks ago
Waiting for a databricks employee to clarify this item.
2 weeks ago
In a UC-managed table, when you check the table properties and look at the storage path
eg: if the Storage path is s3://my_uc_bucket_kr/ae32f4d9-3c84-4583-9197-ffadf942bdf4d/tables/010f12c4-0ca8-4013-9f0c-65d48538d0588
, then metastore_id is `ae32f4d9-3c84-4583-9197-ffadf942bdf4d
and the table ID is 010f12c4-0ca8-4013-9f0c-65d48538d0588
This table ID will be preserved and will not change after every create/replace command, even if the table structure changes.
a week ago
@Krishna_S thanks for your reply.
In a non UC-managed table, is it valid to see a table ID change throughout the life time of the table?
(Also, what value gives me to utilize UC to manage my tables?)
Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!
Sign Up Now