PostgREST
What it is for
Section titled “What it is for”PostgREST turns a PostgreSQL schema into a REST API with no code. The first publishing design used it: Trino copied a query result into serving.staging_api.<name> and PostgREST served it, protected by an HS256 token and the role api_reader.
That path is retired. New published APIs are views served live by the platform API (Views and APIs). PostgREST and the serving catalog are still installed and untouched, shown on the status page as “legacy”, and are candidates for removal together.
Where it lives
Section titled “Where it lives”| Binary | /usr/local/bin/postgrest (step 03, checksum checked) |
| Config | /etc/lake/postgrest/postgrest.conf, jwt.secret |
| Service | postgrest |
| Port | 3000 (127.0.0.1) |
| Database | serving, schema api; anonymous role web_anon |
Check it
Section titled “Check it”systemctl is-active postgrestcurl -s http://127.0.0.1:3000/ # the OpenAPI document of the schemacurl -s http://127.0.0.1:3000/demo_t # the demo table made by step 08How to use it
Section titled “How to use it”Only for the demo chain: Trino writes a table into serving.api, then PostgREST must reload its table list:
trino --execute "CREATE TABLE serving.api.demo2 AS SELECT * FROM lake.demo.t"sudo systemctl kill -s SIGUSR1 postgrest # reload the schema cachecurl -s http://127.0.0.1:3000/demo2web_anon has no access to published data; reading it requires a token signed with jwt.secret.
Things that go wrong
Section titled “Things that go wrong”| Symptom | Likely cause |
|---|---|
| A new table is not served | The schema cache is old: send SIGUSR1 as above |
| Every token is rejected | jwt.secret must have no trailing newline |
| It cannot connect | The authenticator password in postgrest.conf differs from PostgreSQL: re-run step 03 |