Skip to content

fix(deepdoc): keep highest-indexed table in MarkNoMergeTables page scoping - #20125

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
xugangqiang:fix/table-nomerge-nopage-precedence
Sep 23, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
xugangqiang:fix/table-nomerge-nopage-precedence

Conversation

@xugangqiang

Copy link
Copy Markdown
Collaborator

Summary

MarkNoMergeTables (introduced in #20089) indexes table positions per page and appends the page-agnostic (noPage) positions last. It overwrote lastTableTI on every match, so a lower-indexed page-agnostic table sitting at the tail could win over a higher-indexed page-specific table and wrongly receive the NoMerge mark from a following caption/title. This diverges from the original cross-product semantics, which kept the highest-indexed overlapping table.

This only triggers when a table position carries no PageNumbers (the noPage bucket), but the fallback branch exists precisely for that case, so the divergence is real.

Fix

Keep the maximum table index instead of overwriting lastTableTI (table_post.go). The result is order-independent and reproduces the original semantics exactly: the highest-indexed overlapping table wins, regardless of whether noPage positions are appended last.

Test

  • Added TestMarkNoMergeTablesNoPagePrecedence: a box on page 5 overlaps a lower-indexed page-agnostic table and a higher-indexed page-5 table; the following caption must mark the higher-indexed table. Fails before the fix, passes after.
  • Fixed referenceMarkNoMergeTables (the brute-force oracle used by the equivalence tests): it had an early break on the first matching table, so it modelled the lowest-indexed table instead of the original's highest-indexed one — giving false confidence. Removed the break so the oracle faithfully guards the original behavior.

Verification

bash build.sh --test ./internal/deepdoc/parser/pdf/table/ passes (incl. the new test and both cross-page equivalence tests). gofmt / go vet clean.

🤖 Generated with CodeBuddy Code

…oping

MarkNoMergeTables indexes table positions per page and appends the
page-agnostic (noPage) positions last. It overwrote lastTableTI on every
match, so a lower-indexed page-agnostic table sitting at the tail could
win over a higher-indexed page-specific table and wrongly receive the
NoMerge mark from a following caption.

Keep the maximum table index instead of overwriting, which is
order-independent and reproduces the original cross-product semantics
exactly (highest-indexed overlapping table wins).

Also fix referenceMarkNoMergeTables: it had an early break on the first
matching table, so the equivalence test modelled the lowest-indexed table
instead of the original's highest-indexed one, giving false confidence.
Remove the break so the oracle faithfully guards the original behavior.

Adds TestMarkNoMergeTablesNoPagePrecedence locking the precedence.
@xugangqiang xugangqiang added the ci Continue Integration label Sep 23, 2026
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: cf379758-facd-416b-be9b-2494999b1724

📥 Commits

Reviewing files that changed from the base of the PR and between 109dcdb and 7235481.

📒 Files selected for processing (2)
  • internal/deepdoc/parser/pdf/table/table_post.go
  • internal/deepdoc/parser/pdf/table/table_replace_opt_test.go

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

MarkNoMergeTables now keeps the highest-indexed overlapping table even when candidate order differs from table index order. The reference implementation and a regression test cover overlap between page-specific and page-agnostic tables.

Changes

No-merge table precedence

Layer / File(s) Summary
Preserve highest-indexed overlap
internal/deepdoc/parser/pdf/table/table_post.go, internal/deepdoc/parser/pdf/table/table_replace_opt_test.go
The overlap check updates lastTableTI only when a candidate has a higher index. The reference implementation scans all tables, and a regression test checks that the higher-indexed page-specific table receives NoMerge.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 72354

The table-precedence fix is ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: retaining the highest-indexed table in MarkNoMergeTables when page scoping is involved.
Description check ✅ Passed The description includes the required Summary section and provides clear background, the fix, test coverage, and verification details. It is complete and directly related to the changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the tables in a row
Page-specific overlaps take their place
The higher index stays in view
A test keeps that result true
No lower page-agnostic table slips ahead
Then off I hop, with carrots to spare!

Comment @coderabbitai help to get the list of available commands.

@JinHai-CN
JinHai-CN merged commit f97c023 into infiniflow:main Sep 23, 2026
6 checks passed
@xugangqiang
xugangqiang deleted the fix/table-nomerge-nopage-precedence branch September 24, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants