Add partition_key to Metadata so yield matches outlet_events - #71999
Open
Vamsi-klu wants to merge 4 commits into
Open
Add partition_key to Metadata so yield matches outlet_events#71999Vamsi-klu wants to merge 4 commits into
Vamsi-klu wants to merge 4 commits into
Conversation
Docs treated yield Metadata and outlet_events as the same API. Extra already merged onto the same accessor, but partitioned consumers need an explicit key and extra was never a substitute. closes: apache#69117
The upgrade note pointed at an unmerged batching PR, alias docs did not say where partition_key is recorded, and one ADRQ assertion counted the whole table.
The check rejects issue-numbered fragments so the changelog entry links to the change that actually merged. Co-authored-by: Cursor <cursoragent@cursor.com>
The check rejects a fragment named for an older number so the changelog entry links to the change that actually merged. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
cc @dstandish @jroachgolf84 @ashb @kaxil @Lee-W @uranusjr Metadata.partition_key so yield matches outlet_events.add_partitions. Drafted-by: Cursor Grok 4.6; reviewed by @Vamsi-klu before posting |
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.
Add partition_key to Metadata so yield matches outlet_events
closes: #69117
What I did
Added optional
Metadata.partition_key. Sync and async runners calladd_partitionswhen it is set. Extra still merges and never becomes a key. Docs say the two APIs agree for extra, and that a partitioned consumer needs an explicit key.Why I did
Docs said the two APIs were the same. For extra they are. For partitions they were not.
outlet_events[ASSET].extra = {"section": "XY"}does not select a partition, so a partitioned consumer gets no APDR. Reporter also hitoutlet_events=Noneas a positional parameter. Injection already worked; the test keeps it that way.How I did
Metadata.partition_key: str | None = Noneis the last field, soMetadata(asset, extra)still works. Afterextra.update,outlet_events[asset].add_partitions(partition_key). Invalid keys fail the TI. Alias emit does not fan out keys;partition_keyis recorded on the concrete asset accessor only. Alias-only emit still uses the producing Dag run's key.Same partition key still batches onto one APDR. Distinct keys still make distinct runs. No scheduler change.
What's the impact
Users can yield a partition key the same way they call
add_partitions. Extra-only emit to a partitioned consumer still warns and does not create an empty Dag run.What's the testing
task-sdk/tests/task_sdk/execution_time/test_callback_runner.pytest_two_yields_merge_extra_and_collect_partition_keystest_add_partitions_list_matches_two_metadata_yieldstest_extra_does_not_imply_partition_keytest_invalid_partition_key_raisestest_alias_and_partition_key_records_key_on_assettest_alias_as_metadata_asset_with_partition_key_raises_type_errortask-sdk/tests/task_sdk/execution_time/test_task_runner.pytest_emits_shared_extra_on_each_partition_keyairflow-core/tests/unit/models/test_taskinstance.pytest_mapped_outlet_events_extra_injectiontest_mapped_metadata_partition_key_and_extra_per_titest_metadata_invalid_partition_key_fails_task_without_eventairflow-core/tests/unit/jobs/test_scheduler_job.pytest_mapped_producer_partition_keys_match_between_apistest_extra_only_mapped_emit_does_not_create_apdrtest_runtime_partition_key_without_partition_date_still_queuestest_partitioned_event_does_not_queue_non_partitioned_consumertest_multi_partition_payloads_share_merged_extraWas generative AI tooling used to co-author this PR?
Generated-by: Grok 4.6 following the guidelines