Sub topic 6
How a read works: REST calls and pre-signed URLs
This chapter assumes you know what a share, schema and table are, and that you have a basic grasp of HTTPS, REST APIs and bearer tokens. It traces what happens between a recipient's client and the provider when a shared table is read.
The core idea: metadata through the server, data through storage
A Delta Sharing server does not stream table rows. It answers REST requests with metadata and a list of pre-signed URLs. A pre-signed URL is a link to one file in cloud storage (S3, ADLS or GCS) that carries a short-lived signature, so whoever holds it can download that file without storage credentials. The client then fetches the Parquet files straight from storage.
This keeps the sharing server small and lets the storage service handle the heavy transfer.
The REST calls
The client first discovers what it may read, then asks for a table's contents. All calls go under the endpoint from the profile file and send the token in an Authorization: Bearer header.
| Call | Purpose |
|---|---|
| `GET /shares` | List shares the recipient can access |
| `GET /shares/{share}/schemas` | List schemas in a share |
| `GET /shares/{share}/schemas/{schema}/tables` | List tables in a schema |
| `GET /shares/{share}/schemas/{schema}/tables/{table}/version` | Return the current table version |
| `GET /shares/{share}/schemas/{schema}/tables/{table}/metadata` | Return the table protocol and schema |
| `POST /shares/{share}/schemas/{schema}/tables/{table}/query` | Return the files for a read |
The query call is the one that matters for reads. Its body can carry predicate hints, a limit, or a version or timestamp. The server uses them to return fewer files. The response is newline-delimited JSON. It starts with the protocol and table metadata lines, followed by one file line per data file. Each file line has a pre-signed url, a file id, its size, and partition values and statistics.
Why pre-signed URLs
Pre-signed URLs give three practical benefits:
- The provider never gives the recipient storage credentials. The signature covers only the listed files.
- Each URL expires, so a leaked response stops working after a short time.
- Download traffic goes to the storage service. The sharing server only does authorisation and listing.
The cost is that a URL is a bearer capability. Anyone who has it can download that file until it expires. Treat query responses as sensitive and do not log them.
Making the flow visible
The delta-sharing Python client performs these calls for you. You can still call the same endpoint directly to see the first lines of a response. This example uses the standard library and the profile file from the earlier chapter.
import json
import urllib.request
with open("config.share") as f:
profile = json.load(f)
url = (
profile["endpoint"].rstrip("/")
+ "/shares/my_share/schemas/my_schema/tables/my_table/query"
)
request = urllib.request.Request(
url,
data=json.dumps({"limitHint": 10}).encode(),
headers={
"Authorization": "Bearer " + profile["bearerToken"],
"Content-Type": "application/json",
},
method="POST",
)
with urllib.request.urlopen(request) as response:
for line in response.read().decode().splitlines():
print(line[:200])The first line is the protocol, the second is the metadata, and later lines are files. Each file line includes a URL to download, and the signature expiry is visible in its query string.
Common errors
- 401 or 403 from the server. The token is wrong, expired or revoked, or the recipient lacks access to the share. Check
expirationTimein the profile. - 403 from storage. The pre-signed URL has expired. This happens if you list files, wait, then download. Request a fresh
queryresponse and download promptly. - A firewall blocks downloads. The recipient must reach both the sharing endpoint and the storage host that appears in the URLs. Allowing only the first is not enough.
- Reading more than needed. Without a predicate or limit hint, the server returns every file. Hints reduce files listed, but the client may still need to filter rows.
Exercise
A recipient's job lists the files of a large table, then waits two hours before downloading them, and many downloads fail with 403 from the storage host. The token is still valid. What is the likely cause, and what should the job do?
Show answer
The pre-signed URLs from the query response have expired. The token only authenticates calls to the sharing server and does not extend URL lifetime. The job should send a new query request and download the files soon after receiving the response, or let the connector do both steps together.