Skip to content

Trino requester for Plywood (within node) based on Postgres Requester

License

Notifications You must be signed in to change notification settings

nakulgan/plywood-trino-requester

 
 

Repository files navigation

plywood-trino-requester

This is the Trino requester making abstraction layer for plywood and Turnilo (an OSS UI for Druid).

Given a Trino query and an optional context it returns a readable stream of results.

Installation

To install run:

npm install plywood-trino-requester

Usage

In the raw you could use this library like so:

const { trinoRequesterFactory } = require('plywood-trino-requester');
const toArray = require('stream-to-array'); // To get all results as an array

const trinoRequester = trinoRequesterFactory({
  host: 'my.trino.host:8080',
  catalog: 'tpch',
  schema: 'sf1',
  auth: {
    user: 'trino',
    password: 'trino'
  }
});

// Use the requester
const stream = trinoRequester({
  query: 'SELECT "nation", sum("price") AS "TotalPrice" FROM "orders" GROUP BY "nation";'
});

// Stream to array to get all results
toArray(stream)
  .then(results => {
    console.log("Results:", results);
  })
  .catch(err => {
    console.error("Query error:", err);
  });

Although usually you would just pass trinoRequester into the Trino driver that is part of Plywood or configure it for Turnilo.

Configuration for Turnilo

To configure this connector with Turnilo, install this package and then update your Turnilo cluster configuration:

dataCubes:
  - name: trino_example
    clusterName: trino_cluster
    source: trino

clusters:
  - name: trino_cluster
    type: trino
    host: trino-server:8080
    catalog: tpch
    schema: sf1 
    user: trino
    password: trino-password  # Consider using environment variables for credentials

Tests

To run the unit tests:

npm test

Integration Testing with Docker

This project includes a Docker Compose setup for integration testing with real Trino and Turnilo instances.

To start the integration testing environment:

make up

This will start:

  • Trino server with TPC-H dataset on port 8080
  • Turnilo visualization UI on port 9090

To run tests with the Docker environment active:

make integration-test

This command will:

  1. Start Docker containers
  2. Wait for services to initialize
  3. Run the test suite
  4. Shutdown containers when done

For more details on the Docker setup, see docker/README.md.

Future ToDos:

  • Add a Docker container with Trino and test data for full integration testing
  • Add more comprehensive tests for the Trino connection
  • Improve error handling and retry logic

About

Trino requester for Plywood (within node) based on Postgres Requester

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 50.6%
  • TypeScript 32.8%
  • Dockerfile 6.8%
  • Makefile 6.1%
  • Shell 3.7%