LakeQL
Overview
  • Introduction
Configuration
  • Client Setup
Queries
  • Executing Queries
  • Streaming
Metadata
  • Inspecting Catalogs
  • API Reference
GitHub
LakeQL
  1. Trino Client
  2. API Reference

On this page

  1. API Reference
    1. CTrinoClient
      1. setHeader
      2. setRawHeader
      3. getHeaders
      4. query
      5. stream
      6. cancelQuery
      7. cancelAllQueries
      8. getActiveQueries
      9. schemas
      10. tables
      11. views
      12. columns
      13. dropTable
      14. createTable
    2. CTrinoClientError
    3. CTrinoCancellationError
    4. CTrinoQueryError
    5. CTrinoTimeoutError
    6. IRetryConfig
    7. EState
    8. ETrinoHeader
    9. TAuth
    10. IBasicAuth
    11. IBearerAuth
    12. IClientTypeSignature
    13. TClientTypeSignatureParameter
    14. IColumn
    15. IColumnDefinition
    16. IColumnInfo
    17. ICreateTableProps
    18. IDropTableProps
    19. IErrorLocation
    20. IFailureInfo
    21. IGetColumnsProps
    22. IGetSchemasProps
    23. IGetTablesProps
    24. IGetViewsProps
    25. IQueryError
    26. IQueryProps
    27. IQueryResult
    28. IStageStats
    29. IStats
    30. ITrinoClientProps
    31. TTrinoHeaderName
    32. IWarning

API Reference

Auto-generated reference for all exported types, interfaces, and functions from @lakeql/trino-client.

A client for interacting with a Trino cluster via its REST API.

Uses native fetch — no external HTTP dependencies. Supports automatic pagination, streaming via async generators, query cancellation, and configurable retry with exponential backoff.

Constructor

Creates a new TrinoClient instance.

NameType
trinoClientPropsRequiredTrinoClientProps

Properties

NameType
hostRequiredstring
portRequirednumber
headersRequiredHeaders

Methods

setHeader

Sets a well-known Trino request header.

Parameters
NameType
keyRequiredTrinoHeaderName
valueRequiredstring
setRawHeader

Sets an arbitrary request header without key validation.

Parameters
NameType
keyRequiredstring
valueRequiredstring
getHeaders

Returns all currently configured request headers as a plain object.

Returns
Record<string, string>
asyncquery

Executes a SQL statement and collects all result pages into a single array. Automatically follows nextUri pagination until the result set is complete.

Type Parameters
ParameterConstraintDefault
TRow——
Parameters
NameType
queryPropsRequiredQueryProps<TRow>
Returns
Promise<TRow[]>
asyncstream

Executes a SQL statement and returns an async generator that yields rows one at a time as pages are fetched.

Type Parameters
ParameterConstraintDefault
TRow——
Parameters
NameType
queryPropsRequiredQueryProps<TRow>
Returns
Promise<AsyncGenerator<TRow>>
asynccancelQuery

Cancels a running query via its query ID.

Parameters
NameType
queryIdRequiredstring
Returns
Promise<void>
asynccancelAllQueries

Cancels all currently active queries tracked by this client.

Returns
Promise<void>
getActiveQueries

Returns the IDs of all currently active (in-flight) queries.

Returns
string[]
asyncschemas

Lists all schemas in the given catalog.

Parameters
NameType
getSchemasPropsRequiredGetSchemasProps
Returns
Promise<string[]>
asynctables

Lists all base tables in the given catalog and schema.

Parameters
NameType
getTablesPropsRequiredGetTablesProps
Returns
Promise<string[]>
asyncviews

Lists all views in the given catalog and schema.

Parameters
NameType
getViewsPropsRequiredGetViewsProps
Returns
Promise<string[]>
asynccolumns
Parameters
NameType
getColumnsPropsRequiredGetColumnsProps
Returns
Promise<
    | ColumnInfo[]
    | [name: string, type: string, extra: string, description: string][]
  >
asyncdropTable

Drops a table if it exists.

Parameters
NameType
dropTablePropsRequiredDropTableProps
Returns
Promise<void>

true if the statement executed successfully

asynccreateTable

Creates an external table with the given column definitions and storage properties.

Parameters
NameType
createTablePropsRequiredCreateTableProps
Returns
Promise<void>

Base error for Trino client errors.

Constructor

NameType
messageRequiredstring

Human-readable error message.

statusCode?number

HTTP status code from the Trino response.

Properties

NameType
statusCode?number

HTTP status code if available.

Error when a query is cancelled via AbortSignal.

Constructor

NameType
messageRequiredstring

Human-readable cancellation message.

queryId?string

The query ID that was cancelled, if known.

Properties

NameType
queryId?string

The query ID that was cancelled.

Error during Trino query execution (Trino returned an error in the response).

Constructor

NameType
messageRequiredstring

Human-readable error message from Trino.

queryIdRequiredstring

The Trino query ID that produced the error.

errorCodeRequirednumber

Numeric Trino error code.

errorNameRequiredstring

Trino error name (e.g. “TABLE_NOT_FOUND”).

errorTypeRequiredstring

Trino error type (e.g. “USER_ERROR”, “INTERNAL_ERROR”).

Properties

NameType
queryIdRequiredstring

The Trino query ID that failed.

errorCodeRequirednumber

Trino error code.

errorNameRequiredstring

Trino error name (e.g. “TABLE_NOT_FOUND”).

errorTypeRequiredstring

Trino error type (e.g. “USER_ERROR”, “INTERNAL_ERROR”).

Error when a query exceeds its timeout.

Constructor

NameType
messageRequiredstring

Human-readable timeout error message.

queryId?string

The query ID that timed out, if known.

Properties

NameType
queryId?string

The query ID that timed out, if available.

Configuration for automatic retry behavior.

Properties

NameType
maxRetries?number

Maximum number of retry attempts.

Default: 3
initialDelay?number

Initial delay between retries in ms.

Default: 1000
maxDelay?number

Maximum delay between retries in ms.

Default: 30000
backoffMultiplier?number

Multiplier for exponential backoff.

Default: 2
retryableStatusCodes?number[]

HTTP status codes that trigger a retry.

Default: [429, 500, 502, 503, 504]
NameType
QUEUED"QUEUED"
PLANNING"PLANNING"
STARTING"STARTING"
RUNNING"RUNNING"
FINISHED"FINISHED"
CANCELED"CANCELED"
FAILED"FAILED"

Well-known Trino request headers.

NameType
"X-Trino-User"
"X-Trino-Original-User"
"X-Trino-Source"
"X-Trino-Catalog"
"X-Trino-Schema"
"X-Trino-Time-Zone"
"X-Trino-Language"
"X-Trino-Trace-Token"
"X-Trino-Session"
"X-Trino-Role"
"X-Trino-Prepared-Statement"
"X-Trino-Transaction-Id"
"X-Trino-Client-Info"
"X-Trino-Client-Tags"
"X-Trino-Resource-Estimate"
"X-Trino-Extra-Credential"

Authentication credentials — either basic or bearer.

Definition

BasicAuth | BearerAuth
See:BasicAuthBearerAuth

Basic authentication using username and password.

Properties

NameType
typeRequired"basic"
usernameRequiredstring

The authentication username.

passwordRequiredstring

The authentication password.

Bearer token authentication (e.g. OAuth2 or JWT).

Properties

NameType
typeRequired"bearer"
tokenRequiredstring

The bearer token value.

Type signature for complex column types.

Properties

NameType
rawTypeRequiredstring
argumentsRequiredClientTypeSignatureParameter[]

Parameter for type signatures (discriminated union).

Definition

| { kind: "TYPE"; typeSignature: ClientTypeSignature }
  | { kind: "LONG"; longLiteral: number }
  | {
      kind: "VARIABLE"
      namedTypeSignature: {
        name?: string
        typeSignature: ClientTypeSignature
      }
    }
See:ClientTypeSignature

Column definition in query results.

Properties

NameType
nameRequiredstring

Column name.

typeRequiredstring

Type string (e.g. “varchar”, “bigint”, “array(varchar)”).

typeSignature?ClientTypeSignature

Detailed type signature for complex types.

A column definition for CREATE TABLE statements.

Properties

NameType
nameRequiredstring

The column name.

typeRequiredstring

The Trino column type (e.g., “VARCHAR”, “INTEGER”, “TIMESTAMP(3)”).

Column metadata returned by columns() when asObject is true.

Properties

NameType
nameRequiredstring

Column name.

typeRequiredstring

Trino data type (e.g. “varchar”, “integer”, “timestamp(3)”).

extraRequiredstring

Extra column metadata (e.g. partition key info).

descriptionRequiredstring

Column description/comment.

Parameters for creating a table.

Properties

NameType
catalogRequiredstring

The catalog to create the table in.

schemaRequiredstring

The schema to create the table in.

tableRequiredstring

The table name to create.

columnsRequiredColumnDefinition[]

Column definitions (name + type pairs).

properties?Record<string, string>

Optional WITH clause properties (e.g., external_location, format).

ifNotExists?boolean

Whether to use IF NOT EXISTS (default: true).

Parameters for dropping a table.

Properties

NameType
catalogRequiredstring

The catalog containing the table.

schemaRequiredstring

The schema containing the table.

tableRequiredstring

The table name to drop.

Location in the query where an error occurred.

Properties

NameType
lineNumberRequirednumber
columnNumberRequirednumber

Detailed failure information including stack trace.

Properties

NameType
typeRequiredstring
message?string
cause?FailureInfo
suppressedRequiredFailureInfo[]
stackRequiredstring[]
errorLocation?ErrorLocation

Parameters for listing columns of a table.

Properties

NameType
tableRequiredstring

The table to describe.

asObject?boolean

When true, returns typed objects instead of raw tuples.

Default: false

Parameters for listing schemas in a catalog.

Properties

NameType
catalogRequiredstring

The catalog to inspect.

Parameters for listing tables in a catalog and schema.

Properties

NameType
schemaRequiredstring

The schema to inspect.

Parameters for listing views in a catalog and schema.

Properties

NameType
schemaRequiredstring

The schema to inspect.

Error information when a query fails.

Properties

NameType
messageRequiredstring
sqlState?string
errorCodeRequirednumber
errorNameRequiredstring
errorTypeRequired| "USER_ERROR" | "INTERNAL_ERROR" | "EXTERNAL" | "INSUFFICIENT_RESOURCES"
errorLocation?ErrorLocation
failureInfo?FailureInfo

Parameters for executing a SQL query or stream.

Type Parameters

ParameterConstraintDefault
TRow—unknown

Properties

NameType
sqlRequiredstring

The SQL statement to execute.

impersonateAs?string

Optional Trino user to impersonate via X-Trino-User.

signal?AbortSignal

Abort signal for cancelling the query.

transform?(row: unknown[], columns: Column[]) => TRow

Optional transform function to map raw row arrays to typed objects.

Main query results response from Trino.

Type Parameters

ParameterConstraintDefault
TRow—unknown

Properties

NameType
idRequiredstring

The unique query ID.

infoUriRequiredstring

URI for the query info page.

partialCancelUri?string

URI for partial cancellation.

nextUri?string

URI to fetch next batch of results. If absent, query is complete.

columns?Column[]

Column definitions for the result set.

data?TRow[]

Result data rows.

statsRequiredStats

Statistics about query execution.

error?QueryError

Error information if query failed.

warningsRequiredWarning[]

List of warnings.

updateType?string

Type of update operation (e.g. “CREATE TABLE”).

updateCount?number

Number of rows updated (for DML operations).

Statistics for a query execution stage.

Properties

NameType
stageIdRequiredstring
stateRequiredstring
doneRequiredboolean
nodesRequirednumber
totalSplitsRequirednumber
queuedSplitsRequirednumber
runningSplitsRequirednumber
completedSplitsRequirednumber
cpuTimeMillisRequirednumber
wallTimeMillisRequirednumber
processedRowsRequirednumber
processedBytesRequirednumber
physicalInputBytesRequirednumber
failedTasksRequirednumber
coordinatorOnlyRequiredboolean
subStagesRequiredStageStats[]

Statistics about query execution.

Properties

NameType
stateRequiredState
queuedRequiredboolean
scheduledRequiredboolean
progressPercentage?number
runningPercentage?number
nodesRequirednumber
totalSplitsRequirednumber
queuedSplitsRequirednumber
runningSplitsRequirednumber
completedSplitsRequirednumber
cpuTimeMillisRequirednumber
wallTimeMillisRequirednumber
queuedTimeMillisRequirednumber
elapsedTimeMillisRequirednumber
processedRowsRequirednumber
processedBytesRequirednumber
physicalInputBytesRequirednumber
peakMemoryBytesRequirednumber
spilledBytesRequirednumber
rootStage?StageStats

Configuration options for creating a TrinoClient instance.

Properties

NameType
hostRequiredstring

Trino coordinator hostname including protocol (e.g. "https://trino.example.com").

portRequirednumber

Port the Trino coordinator listens on.

authRequiredAuth

Authentication credentials — either basic (username/password) or bearer (token).

catalogRequiredstring

Default catalog used for all queries.

schema?string

Optional default schema used for all queries.

source?string

Source identifier sent as X-Trino-Source header.

Default: "nodejs"
retry?RetryConfig

Retry configuration for failed requests.

timeout?number

Default timeout for queries in milliseconds. No timeout when omitted.

A well-known Trino request header name.

Definition

keyof typeof TrinoHeader
See:TrinoHeader

Warning from Trino during query execution.

Properties

NameType
warningCodeRequired{ code: number; name: string }
messageRequiredstring

Next page

Overview