seanmuth opened a new pull request, #69489:
URL: https://github.com/apache/airflow/pull/69489

   ### What
   
   Adds a `uri` query parameter to `GET /api/v2/assets` that matches an asset 
by its **exact** URI, backed by a new single-column index on `asset.uri`.
   
   ### Why
   
   Today, resolving a single asset when you already know its full URI (for 
example, discovering an `asset_id` before posting to 
`/assets/{asset_id}/events` for cross-deployment dependencies) requires 
`uri_pattern`. That parameter compiles to `ILIKE '%...%'`, 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}` 
(later `GET /assets/{uri}`), but it was **not carried forward** when the 
endpoint migrated to FastAPI under AIP-84 — the single-resource route became 
`GET /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 
`%2F` characters that asset URIs contain.
   
   ### What changed
   
   - New `uri` exact-match filter on `GET /assets` (equality comparison via the 
existing `filter_param_factory`).
   - New non-unique index `idx_asset_uri` on `asset.uri` (the existing unique 
index leads with `name` and cannot serve uri-only lookups), with an Alembic 
migration.
   - Regenerated OpenAPI spec + UI client, updated `REVISION_HEADS_MAP` and 
migration ref doc.
   - Tests: exact-match hits plus negative cases confirming a substring does 
**not** match (unlike `uri_pattern`).
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Opus 4.8, 1M context)
   
   Generated-by: Claude Code (Opus 4.8, 1M context) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   ---
   Drafted-by: Claude Code (Opus 4.8, 1M context) (no human review before 
posting)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to