Repository navigation
Fix duplicated asset events when name_prefix_pattern matches all - #74816
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
Eason09053360
left a comment
There was a problem hiding this comment.
Thanks for the patch! LGTM :)
The "~" match-all alias for name_prefix_pattern is transformed into an empty string, so the truthiness check skipped the join to the asset table while the filter still referenced it, and each event was returned once per asset.
e81ad3c to
7c55d72
Compare
|
Rebased on latest main, CI is green, and it has one approval. @pierrejeambrun @bugraoz93 could one of you take a look when you have time? Thanks. |
|
Hi maintainer, this PR was merged without a milestone set.
|
Backport successfully created: v3-4-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
…hes all (apache#74816) The "~" match-all alias for name_prefix_pattern is transformed into an empty string, so the truthiness check skipped the join to the asset table while the filter still referenced it, and each event was returned once per asset. (cherry picked from commit 322c178) Co-authored-by: Sahil Ray <[email protected]> Co-authored-by: Henry Chen <[email protected]>
…hes all (#74816) (#76570) The "~" match-all alias for name_prefix_pattern is transformed into an empty string, so the truthiness check skipped the join to the asset table while the filter still referenced it, and each event was returned once per asset. (cherry picked from commit 322c178) Co-authored-by: Sahil Ray <[email protected]> Co-authored-by: Henry Chen <[email protected]>
…hes all (#74816) (#76570) The "~" match-all alias for name_prefix_pattern is transformed into an empty string, so the truthiness check skipped the join to the asset table while the filter still referenced it, and each event was returned once per asset. (cherry picked from commit 322c178) Co-authored-by: Sahil Ray <[email protected]> Co-authored-by: Henry Chen <[email protected]>
…hes all (#74816) (#76570) The "~" match-all alias for name_prefix_pattern is transformed into an empty string, so the truthiness check skipped the join to the asset table while the filter still referenced it, and each event was returned once per asset. (cherry picked from commit 322c178) Co-authored-by: Sahil Ray <[email protected]> Co-authored-by: Henry Chen <[email protected]>
closes: #74814
Problem
GET /api/v2/assets/events?name_prefix_pattern=~returns each asset event once per asset in thetable. With two assets and one event each, the response contains every event twice and reports
total_entries: 4instead of2. An emptyname_pattern=takes the same path.Cause
~is the documented "match all" alias forname_prefix_patternand is transformed into an emptystring.
get_asset_eventsjoinsAssetModelonly when a name filter value is truthy, so the join isskipped for
"". The filter itself is still applied, because it skips onlyNone, and it adds apredicate on
asset.namewithout a join condition. The query becomes a cartesian product ofassetand
asset_event. The truthiness check was extended toname_prefix_patternin #64963.Fix
Join
AssetModelwhenever either name filter value is notNone, which matches when the filtersthemselves are applied.
Testing
({"name_prefix_pattern": "~"}, 2)and({"name_pattern": ""}, 2)toTestGetAssetEvents.test_filtering. Both fail without the fix (SQLAlchemy raises itscartesian-product
SAWarning; with the warning ignored,total_entriesis 4 instead of 2) andpass with it.
test_assets.py: 218 passed.generate-openapi-specandcheck-tests-in-the-right-folderswereskipped locally since they need Breeze; the API schema is unchanged.
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.