feat: add native Trino driver

Merged
CE
5mo ago
+1109-83

Summary

  • Add a native Trino driver using trino-client.
  • Wire Trino into connection normalization, registry loading, dbt profile parsing, Docker discovery, environment discovery, SQL explain, and warehouse add guidance.
  • Document Trino configuration, authentication, installation, and support matrix entries.

Details

The previous dbt profile mapping treated trino as PostgreSQL-compatible. This adds a first-class Trino connector instead, with support for:

  • HTTP and HTTPS server URLs
  • catalog and schema defaults
  • Basic authentication
  • bearer token authentication
  • extra headers, session properties, and extra credentials
  • schema/table/column introspection through catalog-scoped information_schema
  • SELECT limit injection with truncation detection

Tests

  • cd packages/drivers && bun test test/trino-unit.test.ts
  • cd packages/opencode && bun test test/altimate/driver-normalize.test.ts test/altimate/connections.test.ts test/tool/project-scan.test.ts test/altimate/tools/sql-explain.test.ts
  • cd packages/opencode && bun run typecheck

Note: bunx tsc -p packages/drivers/tsconfig.json --noEmit still fails on the existing bun:sqlite type resolution issue in packages/drivers/src/sqlite.ts, unrelated to this Trino change.


Summary by cubic

Adds a native Trino driver and integrates it across discovery, dbt, SQL tools, and docs, expanding support to 13 warehouses. Also standardizes tool error handling and prevents sensitive details from appearing in outputs.

  • New Features

    • Native Trino connector using trino-client over HTTP/HTTPS with Basic or Bearer auth (mutually exclusive), extra headers/session/extra credentials, catalog/schema defaults; clamps SELECT limits, detects truncation, recognizes FETCH NEXT, and supports EXPLAIN/EXPLAIN ANALYZE (query history not surfaced).
    • Integration: config aliases (server → connection_string, database/dbname → catalog, token → access_token); dbt trino now maps to the native driver; Docker discovery matches Trino images; env var detection for TRINO_* and DATABASE_URL (trino, trino+http(s), presto); docs updated with a migration note (dbt mapping change and database→catalog, token→access_token) and troubleshooting (catalog required for introspection, auth conflict, protocol/port defaults).
  • Bug Fixes

    • Normalize tool responses for sql_analyze, schema_inspect, lineage_check, and column lineage with shared helpers: unwrap dispatcher envelopes, treat falsy/object errors via message/detail fields, avoid exposing object details, standardize titles/metadata; treat success=false as failure with “Analysis failed.”; lineage tools also fail on inner data.success=false.
    • Trino driver: clearer error when trino-client is present but incompatible; clamps non-numeric/negative limits and detects FETCH NEXT; falls back to protocol-default port when port is invalid; throws if both password and access token are set; warehouse.list shows Database from catalog for Trino.
    • Docs: correct Docker auto‑discovery lists to match actual images (includes Trino; MongoDB not auto‑discovered) and fix minor markdown.

Summary by CodeRabbit

  • New Features

    • Trino added as a supported warehouse with connectivity, query execution, schema/table inspection, and EXPLAIN support.
  • Documentation

    • Guides updated for Trino configuration, auth examples, installation notes, discovery, and support matrix; supported warehouse count updated.
  • Tests

    • New and updated tests covering Trino driver behavior, config normalization, discovery, and EXPLAIN semantics.
  • UX

    • “Warehouse add” surfaces non-blocking post-connect suggestions after successful adds.

Review Change Stack