Deduplicate USC identifiers within import batches#174
Merged
Conversation
…n each batch The JOIN to usc_section/usc_chapter in fetch_sections_batch can produce multiple rows with the same usc_ident (e.g. /us/usc/t10/s20251). ChromaDB's upsert rejects batches that contain duplicate IDs. Added a seen_in_batch set to skip any repeated ident within a single batch before calling upsert. https://claude.ai/code/session_01PaWRuuLei9GtmCUSBUGMfP
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
Added deduplication logic to prevent processing duplicate USC identifiers within a single import batch in the Chroma US Code importer.
Key Changes
seen_in_batchset to track USC identifiers already processed in the current batchusc_identvalues and increment the skip counterImplementation Details
The deduplication occurs early in the row processing loop, before the
build_document()call. This ensures that if the same USC identifier appears multiple times within a batch, only the first occurrence is processed and subsequent duplicates are skipped without unnecessary document construction.https://claude.ai/code/session_01PaWRuuLei9GtmCUSBUGMfP