feat: implement strict mode for max_records_per_run to prevent offset overshoot with composite keys#400
Open
halconel wants to merge 1 commit into
Open
feat: implement strict mode for max_records_per_run to prevent offset overshoot with composite keys#400halconel wants to merge 1 commit into
halconel wants to merge 1 commit into
Conversation
ae926fc to
7bef9c5
Compare
… overshoot with composite keys
7bef9c5 to
e2ea580
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.
Summary
Implements strict mode for
max_records_per_runto fix offset overshoot bug when using composite keys. Whenmax_records_per_runlimits the batch size, the offset calculation now uses only the actually processed records instead of all events for the processed key pairs.Problem
When transform_keys differ from the input table's primary key:
get_batch_input_dfsreads ALL events for those pairs (not just N records)Solution
Strict mode behavior when
max_records_per_runis set:_get_additional_idx_columns)IndexDFWithMetadata(idx_grouped, changed_idx_full_pk)get_batch_input_dfsreads ONLY the specific records fromchanged_idx(strict mode)changed_idxinstead of querying DBlimit_hitguard - safe to update offset with strict modeChanges
datapipe/index_metadata.py- wrapper class for passing metadata with idxdatapipe/step/batch_transform.py- strict mode implementationtests/test_overshoot_composite_keys.py- demonstrates bug and verifies fixtests/test_batch_transform_with_offset_optimization.py- updated for strict mode behaviordocs/max_records_per_run_associativity_plan.md- implementation plan