Sub topic 8
Creating and publishing a share
This chapter assumes you know the provider and recipient roles, the share, schema and table hierarchy, and how a profile file carries an endpoint and bearer token. It also assumes you can read basic SQL and YAML. Here you will publish a share in two ways: with the open-source reference server, and with Databricks SQL on Unity Catalog.
What a provider has to do
Whichever platform you use, the provider does the same four things:
- Pick the Delta tables to expose.
- Group them into a share, with schemas and tables inside it.
- Register a recipient and grant it access.
- Hand the recipient a credential, such as a profile file.
Option 1: the open-source reference server
The reference server reads a YAML file. The file maps each share, schema and table name to a Delta table location in cloud storage. It also sets the host, port, endpoint path and a single bearer token.
version: 1
shares:
- name: "share1"
schemas:
- name: "schema1"
tables:
- name: "table1"
location: "s3a://<bucket>/<path-to-delta-table>"
host: "localhost"
port: 8080
endpoint: "/delta-sharing"
authorization:
bearerToken: "<token>"The names a recipient sees (share1.schema1.table1) come from this file. They do not have to match the folder names in storage. That lets you rename or reorganize storage without breaking recipients.
The server needs read access to the table location. It uses that access to sign short-lived file URLs for recipients. Give the server's identity read-only permission on the data and nothing more.
Then you give the recipient a profile file that points at your server:
{
"shareCredentialsVersion": 1,
"endpoint": "https://sharing.example.com/delta-sharing/",
"bearerToken": "<token>",
"expirationTime": "2030-01-01T00:00:00.0Z"
}The bearerToken must match the one in the server config. The endpoint is the public HTTPS address of the server, including the /delta-sharing path.
Option 2: Databricks with Unity Catalog
On Databricks, you create the share and recipient as catalog objects instead of writing a config file. The four SQL statements below do the whole job.
CREATE SHARE retail_share;
ALTER SHARE retail_share ADD TABLE main.sales.orders;
CREATE RECIPIENT partner_co;
GRANT SELECT ON SHARE retail_share TO RECIPIENT partner_co;Each statement does one step:
CREATE SHAREmakes an empty share.ALTER SHARE ... ADD TABLEpublishes an existing Unity Catalog table into the share.CREATE RECIPIENTregisters the partner as a recipient.GRANT SELECTgives that recipient read access to everything in the share.
Creating a recipient also produces an activation link or credential. For a recipient outside Databricks, it is the equivalent of the profile file above. Send it through a channel you trust.
Choosing between the two options
| Concern | Reference server | Databricks / Unity Catalog |
|---|---|---|
| Where sharing is defined | YAML file | SQL statements |
| Recipients | One shared token in the config | Separate recipient objects, each with its own grant |
| Hosting | You run and secure the server | Managed by Databricks |
| Best for | Trials, custom stacks, non-Databricks platforms | Teams that already use Unity Catalog |
Common errors
- A table is not shared as expected. In the reference server, the
locationmust point at the root of a Delta table, the folder that contains_delta_log. A parent folder will fail. - The server cannot sign URLs. The server's storage credentials are missing or too narrow. Check that it can read the table files.
- The recipient gets an authorization error. The token in the profile does not match the server config, or it has expired. Compare
expirationTimein the profile with the current date. - A grant has no effect on Databricks. The recipient was created, but
GRANT SELECTwas never run on the share. - One token for everyone. With the reference server, every recipient shares the same token. You cannot revoke one partner without changing the token for all of them.
Exercise
A provider uses the reference server and wants to publish a Delta table stored at s3a://acme-data/orders. Recipients should see it as sales.daily.orders under a share named partner_feed. Which parts of the YAML file hold each of those names and the storage path?
Show answer
Under shares, set the share name to "partnerfeed". Under its schemas, set the schema name to "sales"... and note that the table name is "orders" in the stated target "sales.daily.orders" only if the schema is "daily", so the share is partnerfeed, the schema is "daily"...
Exercise
A provider uses the reference server. It wants recipients to see a Delta table stored at s3a://acme-data/orders as the table orders in schema daily, inside a share named partner_feed. How should the YAML be written, and which setting must be exact for the server to read the table?
Show answer
Set the share name to "partnerfeed", the schema name to "daily" and the table name to "orders". Set the table's location to "s3a://acme-data/orders". That location must be the root of the Delta table, the folder that contains deltalog, and the server's storage identity must be able to read it. Recipients then address the table as partnerfeed.daily.orders.
Exercise
On Databricks, you ran CREATE SHARE, ALTER SHARE ADD TABLE and CREATE RECIPIENT, but the partner still cannot read the data. Which statement is missing?
Show answer
GRANT SELECT ON SHARE retailshare TO RECIPIENT partnerco. Creating a recipient does not give it access to any share until you grant it.