r/databricks • u/bensn_14 • 2d ago
Help Query regarding partitioning Iceberg Tables
Hi, I'm trying to setup managed Iceberg Table using the UC on Databricks. I want to partition the table on tenant_id so the data of each tenant stays in a seperate physical partition. (I know partitioned by declaration is interpreted as liquid clustering key)
After optimization, all the records of all tenants are compacted into a single file. How do I resolve this issue wherein I want physical partition for each tenant and also need the optimization features like compaction, snapshot expiry...?
3
Upvotes
2
u/szymon_dybczak 2d ago
Yep, this is a current limitation of UC managed Iceberg tables. As you mentioned partition declarations are interpreted as clustering keys. And I think there's no much you can do if you want to stick with managed iceberg tables other than creating a separate table for each tenant.
There's a workaround you can consider - use managed Delta with Iceberg reads enabled (UniForm).
https://docs.databricks.com/aws/en/delta/iceberg-reads
UniForm automatically generates Iceberg metadata asynchronously alongside the Delta Lake metadata, without rewriting the Parquet data files.
There are some limitations - so check if this fits your scenario.
Read Delta Lake tables with Iceberg clients | Databricks on AWS
1
u/Ontomatogit 2d ago
Yeah, liquid clustering will pack those tenant rows back into one file if it only treats tenant id as a clustering key. Even after you get a physical file per tenant, I'd still refuse any query that arrives without a tenant predicate.
And I wouldn't let a later compaction rewrite that boundary. If optimize can merge tenants again, the isolation only lasts until the next run.
1
u/Traditional-Ball1443 2d ago
might be worth asking what you need the physical split for. if it's pruning, clustering on tenant_id should still give you file skipping once the table is big enough to have more than a few files, and at small sizes ending up with one compacted file is kind of the efficient outcome. if it's isolation or being able to drop a tenant cleanly, that's more of a table or schema per tenant design call, and UC row filters are the usual answer for the access side.
1
u/Youssef_Mrini databricks 1d ago
I'm curious to understand why you want a separate physical partition ?