Presto connection

Presto connection

Connect a task to a Presto coordinator to run distributed SQL over a managed Leoflow Connection. Presto is the upstream project Trino forked from; the Connection shape is identical, only the scheme and hook differ.

Declare the provider

# leoflow.yaml
dag_id: presto_query
connectors:
  - presto

URI shape

presto://<login>:<password>@<host>:<port>/<catalog>

The control plane builds this from the Connection’s fields and exports it as AIRFLOW_CONN_<CONN_ID>. Reserved characters in the password are percent-escaped; PrestoHook un-escapes them on the way out.

Fields the UI asks for

FieldRequiredNotes
Conn Idyese.g. presto_default. Exported as AIRFLOW_CONN_PRESTO_DEFAULT.
Conn Typeyespresto.
HostyesCoordinator hostname, e.g. presto.example.com.
Portusually 8080Coordinator HTTP port (8443 for TLS).
LoginyesPresto user, e.g. etl_user.
PasswordoptionalPassword for PASSWORD auth. Encrypted at rest (ADR 0019).
SchemaoptionalDefault catalog, e.g. hive.
ExtraoptionalJSON: {"protocol":"https","catalog":"hive","schema":"default"}.

Example DAG

# dag.py
from airflow.sdk import DAG, task


@task
def count_rows():
    from airflow.providers.presto.hooks.presto import PrestoHook

    hook = PrestoHook(presto_conn_id="presto_default")
    rows = hook.get_records("SELECT count(*) FROM hive.default.events")
    print("event count:", rows[0][0])


with DAG("presto_query", schedule=None, catchup=False, tags=["example"]):
    count_rows()
# leoflow.yaml
schema_version: "1.0"
dag_id: presto_query
python_version: "3.12"
connectors:
  - presto
connections:
  - presto_default

Security notes

  • TLS: set the coordinator port to 8443 and Extra = {"protocol":"https"}. Never run PASSWORD auth over plain HTTP.
  • Least privilege: scope the Presto user to the catalogs the DAG needs.
  • Never log AIRFLOW_CONN_PRESTO_DEFAULT; it carries the password.
  • ADR 0019 — secret encryption at rest.
  • ADR 0021 — agent secret delivery (AIRFLOW_CONN_<CONN_ID>).
  • TestPrestoConnectionURIShapeIntegration — chain-of-custody delivery test.
  • Trino connection — the modern fork of Presto.