Skip to content

feat(athena): Part 5 — AthenaMetadataAdapter and athena_get_relation - #16374

Open
aoelvp94 wants to merge 2 commits into
dbt-labs:mainfrom
aoelvp94:athena/part-5-metadata-adapter
Open

aoelvp94 wants to merge 2 commits into
dbt-labs:mainfrom
aoelvp94:athena/part-5-metadata-adapter

Conversation

@aoelvp94

@aoelvp94 aoelvp94 commented Sep 18, 2026

Copy link
Copy Markdown

Part of #16252. Related: #13822. Independent PR; the sequence is at the bottom.

Problem

dbt show, compile and run construct a MetadataAdapter; for Athena that arm is todo!() and the process panics. get_relation has the same todo!().

Solution

  • AthenaMetadataAdapter, shaped after ExasolMetadataAdapter: every method is SQL over information_schema through the ADBC connection (tables for relations and types, columns for schemas, schemata for schema listing). No Glue API.
  • athena_get_relation: Athena lowercases every identifier, quoted or not, so the lookup is case-insensitive on both sides; table_type maps BASE TABLE / VIEW; a missing schema yields zero rows, not an error.
  • Athena arm in AdapterImpl::list_relations, leaving the grouped "unsupported" arm.

list_schemas receives the database already quoted; the SQL strips it.

Verification

  • cargo fmt --check, cargo clippy -p dbt-adapter --all-targets --all-features, cargo nextest run -p dbt-adapter -E 'test(athena)' on the pinned toolchain: the unit tests cover the literal escaping and the table_type mapping.
  • Against a real workgroup: dbt show --inline 'select 1 as n' returns one row; dbt show on an incremental model returns real rows; dbt compile on that model logs the information_schema.tables hydration query, evaluates is_incremental() to true and renders the merge watermark query.

Feedback wanted: information_schema queries vs. driver metadata calls once the driver exposes them; this PR chose SQL to stay driver-version independent.

Sequence (independent PRs, each compiles alone against main)

Checklist

  • I have read the contributing guide and understand what's expected of me.
  • I have run this code in development, and it appears to resolve the stated issue.
  • This PR includes tests, or tests are not required or relevant for this PR.
  • This PR has no interface changes.

Fills the two execution-layer `todo!("Athena")` sites so that commands
which construct a metadata adapter (`show`, `compile`, `run`) no longer
panic at `adapter_impl.rs` / `get_relation.rs`.

Athena is Trino over the Glue catalog, so every metadata read is a query
against `information_schema` over the ADBC connection, modelled on the
Exasol adapter:

- `list_relations_schemas_inner`: zero-row probe (`select * from x where
  false limit 0`); Athena returns ResultSetMetadata for empty results, which
  the driver maps to an Arrow schema.
- `list_relations_in_parallel_inner` + `athena::list_relations`: cache
  hydration over `information_schema.tables` (`BASE TABLE` / `VIEW`); a
  missing schema yields zero rows, not an error. `AdapterImpl::list_relations`
  now dispatches Athena here instead of the "not implemented" group, so
  `adapter.list_relations_without_caching` in the vendored macros works.
- `athena_get_relation`: single-row `information_schema.tables` lookup.
- `build_schemas_from_stats_sql` / `build_columns_from_get_columns`:
  `information_schema`-shaped batch; `column_index` is Trino's bigint
  `ordinal_position`.
- Metadata-based freshness and pattern listing return `NotSupported`, as
  Exasol does. Glue exposes no last-altered timestamp via
  `information_schema`.

Identifier literals are lowercased on both sides: Athena folds every
identifier, quoted or not, and Glue stores names lowercased.

`dbt-init/profile_setup.rs` (`dbt init` scaffolding) is the only
`todo!("Athena")` left.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant