Skip to content

Build the ADBC database URI from the connection fields - #74454

Merged
dabla merged 3 commits into
apache:mainfrom
dabla:fix/adbc-hook-uri
Nov 5, 2026
Merged

dabla merged 3 commits into
apache:mainfrom
dabla:fix/adbc-hook-uri

Conversation

@dabla

@dabla dabla commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

AdbcHook.uri handed the driver Airflow's connection URI with the scheme swapped for the dialect. That URI carries the extras in its query string, so any connection with the dialect extra (needed to derive the driver name) produced postgresql://user:pass@host/db?dialect=postgresql, which libpq refuses:

OperationalError: IO: [libpq] Failed to connect: invalid URI query parameter: "dialect"

A full URI in the Host field, as the connection docs describe, was percent-encoded into the path for the same reason (postgresql://postgresql%3A%2F%2Fuser...); only hosts containing :: went through unchanged. In practice the released 0.1.0 hook could not reach PostgreSQL without repeating the URI, password included, in db_kwargs.

This PR:

  • passes a Host that already is a URI or a path through unchanged (://, ::, or starting with /, : or file:), and otherwise builds <dialect>://login:password@host:port/schema from the connection's fields, never from get_uri();
  • stops hiding Port and Schema in the connection form, since they take part in that URI, and gives the fields placeholders;
  • updates the connection docs for the two ways of filling the form;
  • adds test_uri covering the built URI, extras staying out of it, a URI in Host, and the SQLite in-memory and file forms.

Verified against a PostgreSQL 16 with adbc-driver-postgresql 1.12.0: the built URI connects, the previous one fails as quoted above.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.

🤖 Generated with Claude Code

…low's connection URI

AdbcHook.uri handed the driver Airflow's connection URI with the scheme
swapped for the dialect. That URI carries the extras in its query string,
so a connection with the dialect extra (needed to pick the driver) yields
postgresql://user:pass@host/db?dialect=postgresql, which libpq refuses
with "invalid URI query parameter". A full URI in the Host field, as the
docs describe, was percent-encoded into the path for the same reason;
only hosts containing "::" went through unchanged.

The hook now passes a Host that is already a URI or a path through
unchanged (``://``, ``::``, or starting with ``/``, ``:`` or ``file:``)
and otherwise builds ``<dialect>://login:password@host:port/schema``
from the connection's fields. Port and Schema are no longer hidden in
the connection form, since they take part in that URI, and the docs
describe the two ways of filling the form.
@dabla dabla self-assigned this Oct 8, 2026
@dabla
dabla requested a review from potiuk October 8, 2026 09:08
@dabla
dabla marked this pull request as ready for review October 8, 2026 09:08
The ui-field-behaviour change in provider.yaml had not been carried
over to the generated get_provider_info.py, which the
update-providers-build-files check flagged, and the spellcheck did not
know libpq from the new AdbcHook.uri docstring.
@dabla
dabla force-pushed the fix/adbc-hook-uri branch from 4bbadc7 to e0d2437 Compare November 5, 2026 09:49
@dabla
dabla merged commit cc78684 into apache:main Nov 5, 2026
73 checks passed
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.

2 participants