← 输入框|github.com|刷新
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 50.98%. Comparing base (1e5e90c) to head (febedd3).
❗ 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   50.97%   50.98%           
=======================================
  Files         455      455           
  Lines       56994    56996    +2     
  Branches     8321     8322    +1     
=======================================
+ Hits        29055    29057    +2     
  Misses      25954    25954           
  Partials     1985     1985           
Flag Coverage Δ *Carryforward flag
go-feature-server 30.37% <ø> (ø) Carriedforward from 1e5e90c
python-unit 52.45% <100.00%> (+<0.01%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

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 1e5e90c...febedd3. 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.

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 de2ea2c to febedd3 Compare October 27, 2026 17:47

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

2 participants