LakeQL
Overview
  • Package Map
query-builder
  • Filtering
  • Sorting & Paging
  • API Reference
config
  • Runtime Config
  • API Reference
trino-client
  • Client Setup
  • Executing Queries
  • Streaming
  • Metadata
  • API Reference
fabric-client
  • Client Setup
  • Executing Queries
  • API Reference
GitHub
LakeQL
  1. Packages
  2. trino-client
  3. Executing Queries

On this page

  1. Transforming Rows
  2. Impersonation
  3. Cancellation

Executing Queries

Run statements, collect results, and cancel in-flight queries.

query executes a statement and collects all result pages into a single array. It follows Trino's nextUri pagination automatically.

1
2
3
4
const rows = await client.query<{ id: number; status: string }>({
  sql: "SELECT id, status FROM hive.sales.orders",
})

Transforming Rows #

Trino returns rows as positional arrays. Pass a transform to map each row, with its column metadata, into a shape of your choice:

1
2
3
4
5
const rows = await client.query({
  sql: "SHOW COLUMNS FROM hive.sales.orders",
  transform: (row, columns) => ({ name: row[0], type: row[1] }),
})

Impersonation #

Pass impersonateAs to run the statement as another user through the X-Trino-User header:

1
2
await client.query({ sql: "SELECT 1", impersonateAs: "alice" })

Cancellation #

Pass an AbortSignal to cancel a query, or cancel by id:

1
2
3
4
const controller = new AbortController()
const promise = client.query({ sql: longRunningSql, signal: controller.signal })
controller.abort()

The client tracks in-flight queries. Manage them with cancelQuery, cancelAllQueries, and getActiveQueries. An aborted query throws a TrinoCancellationError.

Previous page

Client Setup

Next page

Streaming