LakeQL
Overview
  • Introduction
  • Datasource Contract
  • API Reference
Writing
  • Write Strategies
  • Load Strategies
  • Partitioning
Storage
  • Storage Operations
Trino
  • Connection
  • Write Config
  • Metadata
  • API Reference
Fabric
  • Connection
  • Metadata
  • API Reference
GitHub
LakeQL
  1. Data Sources
  2. Trino
  3. API Reference

On this page

  1. API Reference
    1. VtrinoAdapterFactory
    2. VtrinoAdapterDefinition
    3. VADAPTER_NAME
    4. FvalidateTrinoConfig
    5. FvalidateTrinoWriteConfig
    6. ITrinoConnectionConfig
    7. TTrinoAuth
    8. ITrinoBasicAuth
    9. ITrinoBearerAuth
    10. TTrinoWriteConfig
    11. ITrinoStorageWriteConfig
    12. ITrinoInsertWriteConfig
    13. FclassifyTrinoError
    14. VtrinoDialect
    15. VtrinoResponseNormalizer
    16. VtrinoTypeMapper
    17. FcreateHiveTableManager
    18. IHiveTableManagerConfig
    19. FcreateTrinoWriteStrategy
    20. ITrinoWriteStrategyConfig
    21. FcreateTrinoInsertWriteStrategy
    22. VDEFAULT_BATCH_SIZE
    23. ITrinoInsertWriteStrategyConfig

API Reference

Complete reference for the @lakeql/adapter-trino public API.

The complete public API of @lakeql/adapter-trino, generated from the package's TypeScript source.

Register the adapter with trinoAdapterDefinition in your config. The rest of the surface is the connection config (TrinoConnectionConfig, TrinoAuth), the write strategies and their configs, the SQL dialect, the response normalizer, and the type mapper that the runtime wires together.

Trino adapter factory implementing the neutral AdapterFactory contract.

The factory is stateless: it retains no mutable per-data-source state between calls to createDataSource(), createReadStrategy(), and createWriteStrategy(). All construction methods are synchronous and do not perform network requests, metadata discovery, hidden global registration, or environment lookup.

Definition

AdapterFactory

Typed-config registration value compatible with AdapterDefinition<"trino", TrinoConnectionConfig, unknown, TrinoWriteConfig> from @lakeql/config through structural typing.

The adapter package does NOT import or depend on @lakeql/config. This definition is consumed by defineConfig() to provide compile-time connection-shape inference and per-adapter writeConfig narrowing (TrinoWriteConfig) for Trino data sources.

Intentionally omits registrationOptions and mergeDataSourceConfig because Trino receives a complete explicit connection payload.

Definition

{
  /** Literal adapter name for typed narrowing. */
  adapterName: ADAPTER_NAME,
  /** The exact adapter factory instance. */
  factory: trinoAdapterFactory,
  /** The shared assertion-style config validator. */
  validateDataSourceConfig: validateTrinoConfig,
  /**
   * Pins the adapter's `writeConfig` type to {@link TrinoWriteConfig} at the
   * `defineConfig()` call site. Carries the compile-time type only; runtime
   * validation happens in {@link trinoAdapterFactory.createWriteStrategy}.
   */
  validateWriteConfig: validateTrinoWriteConfig,
} as const

Adapter name literal for the Trino adapter. Used across all modules.

Definition

"trino" as const

Assertion-style validator for TrinoConnectionConfig.

Validates the shape and constraints of a Trino connection configuration payload. Throws a plain Error synchronously when the input is invalid. Error messages identify the offending field by name but never include passwords, bearer tokens, authorization headers, or serialized configuration objects.

The same implementation is used at both the defineConfig() boundary (via trinoAdapterDefinition.validateDataSourceConfig) and the trinoAdapterFactory.createDataSource() boundary, ensuring a single set of validation rules.

Parameters

NameType
configRequiredunknown

The unknown value to validate.

Returns

asserts config is TrinoConnectionConfig

Validates the Trino adapter writeConfig and narrows it by strategy.

An absent strategy is treated as "storage". The "storage" branch is validated by the storage strategy factory, so only its discriminator is checked here. The "insert" branch is validated fully, rejecting surplus fields and malformed options.

Parameters

NameType
writeConfigRequiredunknown

The adapter-owned write configuration to validate.

Returns

asserts writeConfig is TrinoWriteConfig

Configuration for connecting to a Trino coordinator.

Fields mirror TrinoClientProps from @lakeql/trino-client. The outer runtime definition owns adapter selection through its adapter field; this type intentionally does not include an inner adapter discriminator.

Properties

NameType
hostRequiredstring

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

portRequirednumber

Port the Trino coordinator listens on.

catalogRequiredstring

Default catalog for all queries.

schema?string

Optional default schema.

source?string

Source identifier for Trino’s X-Trino-Source header.

authRequiredTrinoAuth

Authentication credentials.

retry?RetryConfig

Retry configuration forwarded unchanged to the Trino client.

timeout?number

Default query timeout in milliseconds.

Authentication credentials for a Trino connection — either basic (username/password) or bearer (token).

Definition

TrinoBasicAuth | TrinoBearerAuth
See:TrinoBasicAuthTrinoBearerAuth

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.

The Trino adapter’s write configuration, a discriminated union on strategy. Selects between the storage (default) and INSERT strategies.

Definition

TrinoStorageWriteConfig | TrinoInsertWriteConfig
See:TrinoStorageWriteConfigTrinoInsertWriteConfig

Storage (external-location + DDL) write strategy configuration.

This is the existing Hive/upload strategy, selected by default. The runtime injects dataSource; the config carries files, serializer, and optional prefix/shadow-table settings (validated by the storage strategy factory itself, not here).

Properties

NameType
strategy?"storage"

Discriminator; defaults to "storage" when omitted.

INSERT write strategy configuration. Writes via INSERT INTO with no object storage.

Properties

NameType
strategyRequired"insert"

Discriminator selecting the INSERT strategy.

batchSize?number

Maximum number of rows per INSERT ... VALUES batch.

Default: 1000
autoCreateTable?boolean

When true, issue CREATE TABLE IF NOT EXISTS before appending, and use a pending-table swap for full_load.

Default: false
tableProperties?Record<string, string>

Optional table properties applied on table creation.

Parameters

NameType
errorRequiredunknown
dataSourceRequiredstring

Returns

DataSourceError

Trino query dialect implementing the neutral QueryDialect contract.

Uses Kysely’s Postgres adapter/compiler since Trino’s SQL dialect is Postgres-compatible for query compilation purposes. The dialect provides Trino-specific SQL fragments for timestamp conversion, pagination, and identifier quoting.

Definition

QueryDialect

Trino response normalizer implementing the neutral ResponseNormalizer contract. Accepts only true as the record sentinel.

Definition

ResponseNormalizer

Shared TypeMapper for Trino SQL types.

Definition

createTypeMapper({
  toPrimitive: TRINO_TO_PRIMITIVE,
  toEngine: PRIMITIVE_TO_TRINO,
})

Creates a HiveTableManager that executes DDL via a DataSource instance. Implements the full TableManager interface with Hive-specific DDL (external tables with PARQUET format and storage locations).

URI scheme is automatically resolved from the files-sdk adapter:

  • S3-compatible providers (s3, minio, r2, wasabi, etc.) → s3a://
  • GCS → gs://
  • Azure → abfss://
  • Unknown providers → s3a:// (default)

The bucket is derived from files.adapter.bucket. If the adapter does not expose a bucket property, externalLocationPrefix must be provided.

Table recreation uses a shadow-table pattern for safe DDL replacement:

  1. Drop pre-existing shadow table (if not retaining)
  2. Create a shadow table to validate DDL
  3. Drop the original table
  4. Create the real table with the validated DDL
  5. Clean up the shadow table (unless keepShadowTables is true)

Parameters

NameType
configRequiredHiveTableManagerConfig

Returns

TableManager

Configuration for the Hive Table Manager.

Properties

NameType
dataSourceRequiredDataSource

The DataSource instance to use for DDL operations.

filesRequiredFiles

The files-sdk instance for deriving external location URIs.

externalLocationPrefix?string

Override for Hive external_location prefix. Auto-derived from files.adapter.name + files.adapter.bucket for known providers. Recommended to set explicitly for production/Azure/custom Hadoop connectors. When provided, used verbatim as the prefix for buildExternalLocation.

keepShadowTables?boolean

When true, shadow tables are not dropped after successful recreation. Default: false.

Creates a Trino-specific DataSourceWriteStrategy that performs the Upload+DDL pattern via the storage write pipeline.

The strategy internally constructs StorageOperations from the provided Files instance and a HiveTableManager from the DataSource + Files. Write calls are delegated to executeWritePipeline with pre-resolved dependencies.

Parameters

NameType
configRequiredTrinoWriteStrategyConfig

Returns

DataSourceWriteStrategy

Configuration for the Trino write strategy factory.

Properties

NameType
filesRequiredFiles

The files-sdk instance for object storage operations.

dataSourceRequiredDataSource

The DataSource instance for DDL operations.

serializerRequiredSerializer

Serializer for data format conversion (e.g. parquetSerializer()).

externalLocationPrefix?string

Override for Hive external_location prefix. Auto-derived from files.adapter.name + files.adapter.bucket for known providers. Recommended to set explicitly for production/Azure/custom Hadoop connectors.

keepShadowTables?boolean

When true, shadow tables are retained after successful DDL. Default: false.

Creates a Trino DataSourceWriteStrategy that writes via INSERT INTO.

Capability requirements are checked eagerly: autoCreateTable and the full_load/full_load_append swap require the data source to report DDL support.

Parameters

NameType
argsRequiredTrinoInsertWriteStrategyConfig

Data source, its name, and INSERT options.

Returns

DataSourceWriteStrategy

A write strategy backed by batched INSERT statements.

Default number of rows per INSERT ... VALUES batch.

Definition

1000

Resolved configuration for createTrinoInsertWriteStrategy.

Properties

NameType
dataSourceRequiredDataSource

Data source used to execute INSERT/DDL statements.

dataSourceNameRequiredstring

Configured runtime name of the data source (for error context).

configRequiredObject

Adapter-owned INSERT write options.

PropertyType
batchSize?number
autoCreateTable?boolean
tableProperties?Record<string, string>

Previous page

Metadata

Next page

Fabric