LakeQL
Introduction
  • Overview
  • Key Concepts
  • Package Map
Getting Started
  • Prerequisites
  • Quickstart
  • Environment Configuration
  • First Run
Architecture
  • System Overview
  • Data Flow
  • Request Lifecycle
Configuration
  • Environment Variables
  • Authentication
  • Trino Connection
create-app
  • Usage
  • Template Structure
  • Post Creation
Contributing
  • Local Development
  • Contribution Guide
Guides
  • Custom Resolvers
  • Extending Schema
  • Deploying
  • Mutations
  • Load Strategies
GitHub
LakeQL
  1. LakeQL
  2. Configuration
  3. Trino Connection

On this page

  1. Connection Configuration
  2. Basic Auth
  3. Bearer Auth
  4. Host and Port
  5. Default Catalog and Schema
  6. Source Header
  7. Connection in Code
  8. Query Execution Flow
  9. Troubleshooting

Trino Connection

Configure the Trino connection including authentication, host settings, and catalog defaults.

Connection Configuration #

LakeQL connects to Trino via its REST API. Both the CLI (for introspection) and the API server (for query execution) use the same connection settings.

Basic Auth #

The default authentication method uses username and password, sent as HTTP Basic Auth:

1
2
3
4
5
HIVE_HOST="https://trino.example.com"
HIVE_PORT=8446
HIVE_USERNAME="my-user"
HIVE_PASSWORD="my-password"

These credentials are included in every request to Trino as Basic Authentication headers.

Bearer Auth #

For environments that use token-based authentication (e.g. OAuth2 access tokens), configure the Trino client to send a Bearer token instead. This is handled at the system user level for write operations where the API impersonates a service account.

Host and Port #

VariableDescriptionExample
HIVE_HOSTProtocol + hostname of the Trino coordinatorhttp://localhost, https://trino.prod.internal
HIVE_PORTHTTP port Trino listens on8080 (default HTTP), 8446 (typical HTTPS)

The full Trino endpoint is constructed as ${HIVE_HOST}:${HIVE_PORT}/v1/statement.

Use https:// for production Trino instances. The Trino client respects the protocol from HIVE_HOST for TLS connections.

Default Catalog and Schema #

1
2
HIVE_CATALOG=hive

The HIVE_CATALOG variable sets the default catalog context. This is used:

  • By the CLI when no --catalog flag is provided
  • By the API server as the default catalog for generated queries
  • In the X-Trino-Catalog session header

Source Header #

1
2
HIVE_SOURCE="lakeql"

The optional HIVE_SOURCE variable sets the X-Trino-Source header, which identifies the application in Trino's query logs. Useful for monitoring and debugging which system submitted a given query.

Connection in Code #

The Trino client is configured internally using these environment variables:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import Bourne from "@hapi/bourne"
import got from "got"

// The client sends requests to Trino's statement endpoint
const endpoint = `${env.HIVE_HOST}:${env.HIVE_PORT}/v1/statement`

// Requests include authentication and session headers
const headers = {
  "X-Trino-User": env.HIVE_USERNAME,
  "X-Trino-Source": env.HIVE_SOURCE ?? "lakeql",
  "X-Trino-Catalog": env.HIVE_CATALOG,
  Authorization: `Basic ${btoa(`${env.HIVE_USERNAME}:${env.HIVE_PASSWORD}`)}`,
}

Query Execution Flow #

When the API server submits a query to Trino:

  1. POST the SQL statement to /v1/statement
  2. Trino returns a response with a nextUri if results aren't ready yet
  3. The client polls the nextUri until the query completes
  4. Final response contains column metadata and row data as arrays
Large result sets are streamed by Trino across multiple pages. The LakeQL trino-client handles pagination internally, but long-running queries may time out depending on your Trino cluster configuration. Use paging.limit in your GraphQL queries to keep result sizes manageable.

Troubleshooting #

SymptomLikely Cause
ECONNREFUSEDTrino is not running or HIVE_HOST/HIVE_PORT is wrong
401 UnauthorizedInvalid HIVE_USERNAME or HIVE_PASSWORD
Catalog does not existHIVE_CATALOG doesn't match a configured Trino catalog
Schema does not existThe target schema hasn't been created in Trino yet
Query timeoutTrino cluster is overloaded or the query scans too much data

Previous page

Authentication

Next page

create-app