Skip to content

Conversation

@whitepowder
Copy link
Contributor

@whitepowder whitepowder commented Aug 25, 2025

Summary

Add a DbtTrinoHook to airflow_dbt_python/hooks/target.py for dbt-trino.

  • Auto-registered via metaclass with airflow_conn_types=('trino',)
  • Extras-first behavior: supports legacy 2.2.0 style where everything is in conn.extra
  • Maps databasecatalog for dbt-trino; explicit catalog overrides the fallback
  • Accepts host/port/user/password/schema from extras to keep 2.2.0 compatibility
  • Optional passthroughs: session_properties, http_headers, role, client_tags, source

Example Airflow connection (legacy extras-only)

{
  "type": "trino",
  "method": "ldap",
  "user": "usert",
  "password": "pass",
  "host": "trino.example",
  "port": 443,
  "http_scheme": "https",
  "database": "example",
  "schema": "example",
  "verify": false
}

Tests

  • tests/hooks/test_trino.py validates:
    • extras-only mapping (host/port/user/password/schema)
    • databasecatalog fallback and explicit catalog override

Notes

  • No override of get_dbt_details_from_connection.
  • No breaking changes to existing hooks.

@tomasfarias tomasfarias changed the title add DbtTrinoHook feat: add DbtTrinoHook Aug 26, 2025
@tomasfarias tomasfarias linked an issue Aug 26, 2025 that may be closed by this pull request
Copy link
Owner

@tomasfarias tomasfarias left a comment

Choose a reason for hiding this comment

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

The changes look good, although I am running tests to confirm.

I do have one question: There is a plugin package for dbt: dbt-trino. If that plugin is required when using dbt normally it will likely also be required here.

I am not familiar with Trino but could you verify whether this package is required or that the hook works without it?

Ideally, we would have test coverage support to verify either way, but I will understand if we cannot reproduce a Trino environment in CI.

@whitepowder
Copy link
Contributor Author

@tomasfarias
Thanks! Yes — dbt-trino is required at runtime, same as when using dbt directly.

This hook only builds the dbt profile dict (host/port/catalog/schema/etc.). It doesn’t talk to Trino or import the adapter. When dbt runs, it loads adapters via entry points; without dbt-trino installed, dbt will error (e.g. “Could not find adapter type ‘trino’”).

I can add a small docs note, and (optionally) an extra in pyproject.toml so users can install it with:

[project.optional-dependencies]
trino = [
  "dbt-trino>=1.8,<2.0"
]

@tomasfarias
Copy link
Owner

I can add a small docs note, and (optionally) an extra in pyproject.toml so users can install it with:

I don't think a docs note is necessary as we currently don't call out other specific adapters.

Adding an extra dependency introduces additional build time, as we have more dependencies to resolve, and would require updating the lockfile. On the other hand, it can provide users a quicker way to install everything, and some runtime guarantees (although that only goes so far with Python).

Anyways, all in all, I think this is fine, and we can release it as-is. We can always add dependencies later.

Copy link
Owner

@tomasfarias tomasfarias left a comment

Choose a reason for hiding this comment

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

CI tests are passing.

@tomasfarias
Copy link
Owner

tomasfarias commented Aug 26, 2025

@whitepowder I'll release this later today as airflow-dbt-python v3.1.0. Will default to your testing, as I have no resources at the moment to test Trino. Thanks for the work!

@tomasfarias tomasfarias merged commit a46f7e5 into tomasfarias:master Aug 26, 2025
27 checks passed
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.

Feature: Add support for Trino and conn_type="trino"

2 participants