Add exact-match uri filter to GET /assets endpoint#69489
Open
seanmuth wants to merge 1 commit into
Open
Conversation
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 is 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 an asset by its exact URI using an
equality comparison, 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.
d549e9b to
5416302
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)