Skip to content

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

Merged
ntkathole merged 1 commit into
feast-dev:masterfrom
patelchaitany:fix/text-chunker-trailing-chunk
Nov 11, 2026
Merged

ntkathole merged 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.80%. Comparing base (bf74b10) to head (3c1d375).
❗ 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.79%   51.80%           
=======================================
  Files         458      458           
  Lines       57715    57717    +2     
  Branches     8483     8484    +1     
=======================================
+ Hits        29896    29898    +2     
  Misses      25793    25793           
  Partials     2026     2026           
Flag Coverage Δ
go-feature-server 30.58% <ø> (ø)
python-unit 53.30% <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 bf74b10...3c1d375. 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

@patelchaitany
patelchaitany force-pushed the fix/text-chunker-trailing-chunk branch 5 times, most recently from 88bde94 to 5159d94 Compare November 11, 2026 04:26
@patelchaitany
patelchaitany force-pushed the fix/text-chunker-trailing-chunk branch from 5159d94 to 3c1d375 Compare November 11, 2026 05:34
@ntkathole
ntkathole force-pushed the fix/text-chunker-trailing-chunk branch from 3c1d375 to db577fd Compare November 11, 2026 14:38
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>
@ntkathole
ntkathole force-pushed the fix/text-chunker-trailing-chunk branch from db577fd to 195d547 Compare November 11, 2026 14:39
@ntkathole
ntkathole merged commit 2f7f57e into feast-dev:master Nov 11, 2026
3 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

4 participants