Add exact-match uri filter to GET /assets endpoint#69489
Conversation
d549e9b to
5416302
Compare
|
Thanks for the review! Pushed
Regenerated the OpenAPI spec + UI client. Locally the asset filter tests (14) and a fresh-DB up → down → up migration check both pass. Drafted-by: Claude Code (Opus 4.8, 1M context) (no human review before posting) |
3c05602 to
24b2e92
Compare
|
Heads-up on CI: the only red check is Everything substantive is green: the asset filter tests, mypy, ruff, migration/revision-heads checks, and the full test matrix all pass (138 passing). I also validated the change end-to-end on a local 3.2.1 env and a real Astro deployment (Runtime 3.2-4): exact This is ready for another look. Thanks again for the review! Drafted-by: Claude Code (Opus 4.8, 1M context) (no human review before posting) |
pierrejeambrun
left a comment
There was a problem hiding this comment.
Nice, thanks
LGTM, needs a rebase to fix conflicts, unrelated CI failures should go away too.
Resolving a single asset by its full URI currently requires uri_pattern,
which compiles to ILIKE '%...%' and cannot use a database index, so it
degrades to a full table scan on large asset tables. This restores the
fast, index-backed exact-URI lookup that the Airflow 2 REST API exposed
via GET /datasets/{uri} but that was not carried forward when the endpoint
moved to FastAPI under AIP-84.
The uri query parameter matches assets by exact URI using an equality
comparison and accepts repeated values (?uri=a&uri=b) to resolve several
assets in one call, backed by a new single-column index on asset.uri (the
existing unique index leads with name and cannot serve uri-only lookups).
Passing it as a query parameter rather than a path segment avoids the
URI-encoding problems that path parameters have with the '/' and ':'
characters in asset URIs.
24b2e92 to
ff3f5ec
Compare
What
Adds a
uriquery parameter toGET /api/v2/assetsthat matches an asset by its exact URI, backed by a new single-column index onasset.uri.Why
Today, resolving a single asset when you already know its full URI (for example, discovering an
asset_idbefore posting to/assets/{asset_id}/eventsfor cross-deployment dependencies) requiresuri_pattern. That parameter compiles toILIKE '%...%', which cannot use a B-tree index and degrades to a full table scan on large asset tables — the API docs themselves warn about this.The Airflow 2 REST API offered a fast exact lookup via
GET /datasets/{uri}(laterGET /assets/{uri}), but it was not carried forward when the endpoint migrated to FastAPI under AIP-84 — the single-resource route becameGET /assets/{asset_id}(integer PK only). This PR restores the exact-URI lookup as a query parameter.Passing the URI as a query parameter rather than a path segment also avoids the URI-encoding problems path parameters have with the
/,:, and%2Fcharacters that asset URIs contain.What changed
uriexact-match filter onGET /assets(equality comparison via the existingfilter_param_factory).idx_asset_urionasset.uri(the existing unique index leads withnameand cannot serve uri-only lookups), with an Alembic migration.REVISION_HEADS_MAPand migration ref doc.uri_pattern).Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 4.8, 1M context) following the guidelines
Drafted-by: Claude Code (Opus 4.8, 1M context) (no human review before posting)
Important
🛠️ Maintainer triage note for @seanmuth · by
@potiuk· 2026-07-08 15:38 UTCHelpful heads-up from the maintainers — please address before this PR can be reviewed:
CI image checks / Static checks). See the contributor guide.Full criteria: Pull Request quality criteria.
The ball is in your court — you've been assigned to this PR. Fix the above, then mark it Ready for review.
Automated triage — may be imperfect; a maintainer takes the next look.