Skip to content

feat: Trino and Amazon Athena warehouse connectors - #427

Merged
vladenisov merged 2 commits into
mainfrom
feat/trino-athena
Oct 8, 2026
Merged

vladenisov merged 2 commits into
mainfrom
feat/trino-athena

Conversation

@vladenisov

Copy link
Copy Markdown
Collaborator

Summary

Two new warehouse types, trino and athena.

  • Trino — via the trino client:
    • Buckets are zone-less timestamp(3) on the UTC wall clock: 1h/1d use date_trunc; 15m, 6h and weeks floor onto the epoch grid (weeks anchored at WEEK_ORIGIN, a Monday).
    • GROUP BY uses ordinals.
    • Regex contracts are probed per expectation, because Joni refuses (?P<name>…).
    • json columns are documents. varchar columns can be parsed as JSON.
  • Amazon Athena (engine v3, a Trino fork) — via pyathena:
    • It reuses the Trino SQL with a region-only host: the host resolves only to athena.<region>.amazonaws.com(.cn).
    • There is no per-query timeout, so a timer cancels the query (StopQueryExecution).
  • Outbound safety:
    • Trino pins the vetted address through a requests adapter. The configured name is kept for TLS and the Host header. Other hosts or ports are refused, redirects are off, and environment proxies are ignored.
    • A password over http is refused.
    • Values are quoted literals with ' doubled. Trino has no backslash escapes, and the client renders bound parameters the same way.
  • Migration: e6a8c0d2f4b6.
  • Settings and UI: settings schemas are split into schemas/trino_settings.py and connection_settings_base.py. The frontend has connection fields, SQL dialect, formatter and metric templates for both engines.
  • Docs: connection how-to (including the Athena IAM policy), parity table rows, security notes, and the engine lists updated everywhere they appear.
  • CI:
    • A trino job runs the value-conformance suite against digest-pinned trinodb/trino:483, with a JUnit check that nothing was skipped.
    • athena-value-conformance.yml runs on release tags once ATHENA_VALUE_CONFORMANCE_ENABLED is set.

Test plan

  • Backend: ruff, ruff format, and mypy are clean.
  • Targeted pytest: 1066 passed.
  • Trino value conformance: 39 passed, 0 skipped, against a local Trino 483.
  • Frontend: build, lint, bundle budget, and the touched vitest files pass.
  • The Trino CI job, on GitHub.
  • E2E spec trino-athena-data-source.spec.ts, in CI.
  • Athena against a live account. This is not done yet: its tests mock pyathena, and the docs mark Athena as believed, not proven.

🤖 Generated with Claude Code

One Trino SQL layer (trino_sql / trino_expr / trino_queries) behind two
drivers:

- TrinoAdapter (Trino and Starburst, `trino` client): https with basic auth,
  or an unauthenticated coordinator; the database field is the catalog, plus
  a default schema and schema allowlist. Session time zone UTC and
  query_max_run_time from the source's timeout. Every request, result pages
  included, goes to the vetted address with the configured name kept for TLS;
  other hosts and redirects are refused; a password is only sent over HTTPS.
- AthenaAdapter (pyathena over boto3) subclasses it: region-only host (boto3
  only ever reaches athena.<region>.amazonaws.com), workgroup, S3 result
  location, catalog, access key. The deadline is enforced client side with
  StopQueryExecution.

SQL: date_trunc for 1h/1d and integer epoch-second arithmetic for 15m/6h/weeks
anchored at WEEK_ORIGIN, on the UTC wall clock (zoned columns AT TIME ZONE
'UTC'); buckets are zone-less timestamp(3). Window literals follow the column
family. json columns via json_extract / json_extract_scalar and
map_keys(CAST(... AS map(varchar, json))); varchar columns can be parsed as
JSON. count_if conditional aggregates, try_cast to double for range contracts,
regex patterns probed per expectation with regexp_like (Joni). GROUP BY by
ordinal (Trino refuses output aliases). Identifiers double-quoted; values
written as single-quoted literals with the quote doubled - Trino literals have
no escapes, the client would render bound parameters into the same literal,
and Athena's execution parameters take literal text.

db_type gains trino and athena (migration), typed connection settings,
measure-validator dialect rules, fact-condition LIKE escaping, the
data-source form, starter templates, docs and an e2e spec. A `trino` CI job
runs the value suite against a digest-pinned trinodb/trino 483 coordinator;
the Athena value suite runs on release tags once
ATHENA_VALUE_CONFORMANCE_ENABLED is set and has not been run live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 22:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…stops it

The cursor has no query id until StartQueryExecution returns; a deadline that
fired first was a silent no-op and the query ran on to the workgroup's limit.
The deadline now keeps looking until the id appears. A BaseException during
execute (a worker soft time limit) also stops the timer and closes the cursor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vladenisov
vladenisov merged commit 2150f68 into main Oct 8, 2026
18 checks passed
@vladenisov
vladenisov deleted the feat/trino-athena branch October 9, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants