This Trino connector stores views to the local filesystem or a Postgresql database, without requiring Hive metastore or object storage services.
Many thanks to Roey Ogen and @MirerRon for your feedback and contributions!
- Trino 478
- Java 24
- Maven 3.9.8 or higher
- Postgresql 10 or higher (optional)
Download Trino 478, and export TRINO_HOME as a shell variable:
export TRINO_HOME=$HOME/Downloads/trino-478Build and install connector:
mvn clean package && rm -rf $TRINO_HOME/plugin/viewzoo && cp -r ./target/viewzoo-478 $TRINO_HOME/plugin/viewzooWarning
Don't run Trino yet, you'll need to configure local storage or JDBC storage first.
Views can be stored directly on the Trino server's filesystem (as JSON files), without requiring any other infrastructure. This option is intended for development and prototyping, and for very lightweight deployments.
Create a local directory to store views:
rm -rf /tmp/viewzoo && mkdir -p /tmp/viewzooCreate a $TRINO_HOME/etc/catalog/viewzoo.properties configuration file like this:
connector.name=viewzoo
viewzoo.storage_type=filesystem
viewzoo.dir=/tmp/viewzooRun Trino:
cd $TRINO_HOME && bash bin/launcher runCaution
Trino will fail to start if viewzoo.dir does not exist, or if Trino doesn't have read and write permissions.
Caution
If running Trino in a Docker container, ensure viewzoo.dir is mapped to a persistent volume or host directory. Without this, view definitions will be lost when the container is upgraded or recreated. To verify your volume mount is configured correctly, run:
docker inspect <container_name> --format='{{json .Mounts}}' | jq '.[] | select(.Destination == "/path/to/viewzoo.dir")'Replace /path/to/viewzoo.dir with your actual viewzoo.dir path. If this returns mount information showing a Source outside the container, your views are safely persisted. If it returns nothing or shows no external Source, your views will be lost on container upgrade.
Tip
Filesystem storage enables a unique collaboration pattern: teams can share view definitions through git without requiring a traditional database or network file share. By storing views as JSON files in a version-controlled directory, view definitions become part of your application's source code, with full revision history, pull request reviews, and branch-based development. This approach is particularly valuable for development environments, CI/CD pipelines, and scenarios where you need view definitions to be as portable and reviewable as your application code itself.
Views can alternatively be stored as rows in a local or remote Postgres database. This option is preferred for multi-container and Kubernetes deployments, and production environments in general. JDBC storage makes it easy to include views in regular database backups and avoids the sharing, permission, and upgrade issues that can occur with filesystem storage in containerized production environments.
Run a local Postgres server if necessary:
docker run -d --name viewzoopg -e POSTGRES_PASSWORD=secretpassword -p 5432:5432 postgres:16Create a $TRINO_HOME/etc/catalog/viewzoo.properties configuration file like this:
connector.name=viewzoo
viewzoo.storage_type=jdbc
viewzoo.jdbc_url=jdbc:postgresql://localhost:5432/postgres
viewzoo.jdbc_user=postgres
viewzoo.jdbc_password=secretpasswordRun Trino:
cd $TRINO_HOME && bash bin/launcher runCaution
Trino will fail to start if Postgres is not running or reachable, or if JDBC authentication fails.
When finished testing, remove local Postgres server:
docker stop viewzoopg; docker rm viewzoopgViews managed by this connector behave just like regular Trino views, but we'll walk through some simple examples anyway.
Connect your favorite SQL client (like DBeaver or Trino CLI) to your Trino server.
Create a view with static data:
create view viewzoo.example.hello as select * from (values ('A', '1')) as t (key, value)Select rows from the view:
select * from viewzoo.example.helloShow view columns and types:
describe viewzoo.example.helloReplace view with different static data:
create or replace view viewzoo.example.hello as select * from (values ('A', '1'), ('B', '4')) as t (key, value)Replace view with query to system catalog:
create or replace view viewzoo.example.hello as select node_id as key, http_uri as value from system.runtime.nodesExamine current view definition:
show create view viewzoo.example.helloDelete the view:
drop view viewzoo.example.helloCaution
This connector does not support defining or using tables, only views.
Caution
Materialized views are not supported. Use Iceberg for view storage in this case.
Caution
While this connector probably works with multiple versions of Trino, it has only been tested with Trino 478.
© 2024-2025 Rob Dickinson (robfromboulder)