Sub topic 5
Shares, schemas and tables
This chapter covers how Delta Sharing organizes data into shares, schemas and tables. It assumes you know what a provider and a recipient are, and that you understand tables, schemas and SQL. It also assumes you have a rough idea of cloud object storage such as S3, ADLS or GCS.
The three-level hierarchy
A provider does not expose a whole data lake to a recipient. The provider publishes a small, named selection of Delta tables. Delta Sharing arranges that selection in three levels:
- A share is the unit of access. It is a named collection of schemas and tables that a provider grants to one or more recipients.
- A schema groups tables inside a share. It works like a schema or database in SQL.
- A table is a Delta table that the provider has added to the share.
A recipient addresses a table by three names joined with dots: share.schema.table. You will use this form in the table URLs in later chapters.
Names are aliases, not storage paths
The names a recipient sees are not the real names of the underlying tables. In the open-source reference server, each share entry maps a share.schema.table name to a storage location. A provider can therefore:
- rename a table for the audience, for example expose
orders_v3asorders - put tables from different source locations into one schema
- add or remove tables without changing the source data
Here is part of a reference server configuration:
version: 1
shares:
- name: "share1"
schemas:
- name: "schema1"
tables:
- name: "table1"
location: "s3a://<bucket>/<path-to-delta-table>"A recipient sees share1.schema1.table1. The bucket and path stay on the provider side. The recipient only ever receives pre-signed file URLs for the table's data files, which a later chapter explains.
Access is granted per share
The share is the access boundary. A recipient who has been granted a share can list and read every table in it. A recipient cannot read tables in shares they were not granted. Delta Sharing has no per-table grant inside a share. If two partners need different tables, create two shares.
On Databricks with Unity Catalog, the provider creates the share and adds tables to it:
CREATE SHARE retail_share;
ALTER SHARE retail_share ADD TABLE main.sales.orders;The full provider workflow, including recipients and grants, comes in a later chapter.
Listing what you can see
A recipient can discover shares, schemas and tables with the REST API or with SharingClient. The client lists only what the recipient has been granted:
import delta_sharing
client = delta_sharing.SharingClient("config.share")
for share in client.list_shares():
print("share:", share.name)
for table in client.list_all_tables():
print(f"{table.share}.{table.schema}.{table.name}")The calls follow the hierarchy. list_shares returns shares, and list_all_tables walks every schema in every share. The protocol also defines listing schemas within a share and tables within a schema. SharingClient exposes these as list_schemas and list_tables.
Common errors
- Granting too much in one share. Because access is per share, adding a table gives every recipient of that share access to it. Check the recipient list before you add a table.
- Misspelled table URL. The URL is the profile path, a
#, thenshare.schema.table. A wrong name usually returns a "not found" error. Runlist_all_tablesand copy the names. - Assuming the source name is visible. Recipients see the alias. Do not rely on source table names in documentation you give them.
- Expecting to see everything. An empty listing usually means the recipient has no grants, or the profile points at the wrong server.
Exercise
A partner should read the orders table but not the customers table. Both tables are in share1, and a second partner already needs customers. What do you do?
Show answer
Access is granted per share, so create a second share that contains only orders and grant it to the first partner. Keep customers in the existing share for the second partner. Both shares can point to the same underlying Delta tables.