Skip to content

fix: Stop TextChunker once a chunk reaches the end of the text - #7078

Open
patelchaitany wants to merge 1 commit into
feast-dev:masterfrom
patelchaitany:fix/text-chunker-trailing-chunk
Open

patelchaitany wants to merge 1 commit into
feast-dev:masterfrom
patelchaitany:fix/text-chunker-trailing-chunk

Conversation

@patelchaitany

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

TextChunker._chunk_by_words kept advancing its sliding window after a chunk had already reached the end of the text. If the leftover window still had at least min_chunk_size words, it was emitted as another chunk whose words were all in the previous chunk. With the default ChunkingConfig, a 100-word document produced a redundant w80–w99 chunk, and DocEmbedder would embed and store it as its own row.

This PR breaks out of the loop right after the chunk that reaches the end of the text. Texts that do not reach the end produce the same output as before.

Which issue(s) this PR fixes:

Fixes #7063

Checks

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests
  • Integration tests
  • Manual tests
  • Testing is not required for this change

Misc

Added test_no_trailing_chunk_contained_in_previous, which fails before this change and passes after it. The existing TestTextChunker tests pass, and ruff check and format are clean.

🤖 Generated with Claude Code

@patelchaitany
patelchaitany requested a review from a team as a code owner October 27, 2026 12:09
@codecov-commenter

codecov-commenter commented Oct 27, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.28%. Comparing base (b576c45) to head (8591807).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #7078   +/-   ##
=======================================
  Coverage   51.28%   51.28%           
=======================================
  Files         458      458           
  Lines       57409    57411    +2     
  Branches     8415     8416    +1     
=======================================
+ Hits        29443    29445    +2     
  Misses      25957    25957           
  Partials     2009     2009           
Flag Coverage Δ
go-feature-server 30.58% <ø> (ø)
python-unit 52.76% <100.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
sdk/python/feast/chunker.py 83.33% <100.00%> (+0.64%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b576c45...8591807. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@patelchaitany
patelchaitany force-pushed the fix/text-chunker-trailing-chunk branch 2 times, most recently from febedd3 to fd8350d Compare November 2, 2026 07:48

@shuchu shuchu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

The sliding window kept advancing after the last word was covered, so
a leftover window with at least min_chunk_size words was emitted as an
extra chunk whose words were all in the previous chunk. Break out of
the loop right after the chunk that reaches the end of the text.

Fixes feast-dev#7063

Signed-off-by: Chaitany Patel <patelchaitany93@gmail.com>
@patelchaitany
patelchaitany force-pushed the fix/text-chunker-trailing-chunk branch from fd8350d to 8591807 Compare November 4, 2026 06:46

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextChunker emits a trailing chunk that is fully contained in the previous chunk

3 participants