Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

TypeScript client library for Trino

License

NotificationsYou must be signed in to change notification settings

trinodb/trino-js-client

Repository files navigation

ATrino client forNode.js.

Join us onTrino Slack in#core-dev to discuss and helpthis project.

@latestit-testslicense

Features

  • Connections over HTTP or HTTPS
  • Supports HTTP Basic Authentication
  • Per-query user information for access control

Requirements

  • Node 12 or newer.
  • Trino 0.16x or newer.

Install

npm install trino-client oryarn add trino-client

Usage

For additional info on all available methods and typeshave a look at theAPI documentation.

Create a Trino client

consttrino:Trino=Trino.create({server:'http://localhost:8080',catalog:'tpcds',schema:'sf100000',auth:newBasicAuth('test'),});

Submit a query

constiter:Iterator<QueryResult>=awaittrino.query('select * from customer limit 100');

Iterate through the query results

forawait(constqueryResultofiter){console.log(queryResult.data);}

Alternative: map and aggregate the data

constdata:QueryData[]=awaititer.map(r=>r.data??[]).fold<QueryData[]>([],(row,acc)=>[...acc, ...row]);

Examples

More usage examples can be found in theintegration tests.

Build

Use the following commands to build the project locally with your modifications,and in preparation to contribute a pull request.

Requirements:

  • yarn

Install dependencies:

yarn install --frozen-lockfile

Lint the source code:

yarn test:lint

Build:

yarn build

A successful build run does not produce any message on the terminal.

Integration test

Integration tests run against a Trino server running on your workstation.

Requirements:

Create a cluster:

kind create cluster

Deploy Trino:

kubectl apply -f tests/it/trino.yml

Wait for pods to be ready:

kubectlwait --for=condition=ready pods -n trino-system --all --timeout=120s

Ensure Trino is running and available on port8080. Run the followingcommand in a separate terminal:

kubectl -n trino-system port-forward svc/trino 8080:8080

Run tests:

yarn test:it --testTimeout=60000

Output should look similar to the following:

 PASS  tests/it/client.spec.ts  trino    ✓ exhaust query results (1567 ms)    ✓ close running query (200 ms)    ✓ cancel running query (17 ms)    ✓ get query info (1 ms)    ✓ client extra header propagation    ✓ query request header propagation (88 ms)    ✓ QueryResult has error info    ✓ QueryInfo has failure info (1 ms)    ✓ prepare statement (98 ms)    ✓ multiple prepare statement (432 ms)Test Suites: 1 passed, 1 totalTests:       10 passed, 10 totalSnapshots:   0 totalTime:        3.457 sRan all test suites matching /tests\/it/i.

Remove the cluster:

kind delete cluster

Contributing

Follow theTrino contribution guidelinesand contact us on Slack and GitHub.

CopyrightTrino JS Client contributors 2022-present

Releasing

Releases are automated with GitHub Actions and only require a pull requestthat updates the version inpackage.json. For example, seePR 723

Packages

No packages published

Contributors11


[8]ページ先頭

©2009-2025 Movatter.jp