Skip to content

refactor: move each TableScan subclass to its own file - #994

Merged
wgtmac merged 1 commit into
apache:mainfrom
manuzhang:agent/split-table-scan
Oct 11, 2026
Merged

wgtmac merged 1 commit into
apache:mainfrom
manuzhang:agent/split-table-scan

Conversation

@manuzhang

Copy link
Copy Markdown
Member

What

Move each TableScan subclass into its own header and source file:

  • DataTableScan → iceberg/data_table_scan.{h,cc}, together with the scan
    report helpers that only it uses.
  • IncrementalAppendScan → iceberg/incremental_append_scan.{h,cc}.
  • IncrementalChangelogScan → iceberg/incremental_changelog_scan.{h,cc}.

iceberg/table_scan.{h,cc} keep TableScan, IncrementalScan,
TableScanBuilder, the scan task types and TableScanContext. The
extern template declaration of each TableScanBuilder specialization moves
next to its scan class, while the explicit instantiations stay in
table_scan.cc with the builder's member definitions. ResolvePlanFiles stays
in table_scan.cc with the snapshot range helpers it calls and is explicitly
instantiated for FileScanTask and ChangelogScanTask.

The moved code is unchanged. cpp20_compatibility_internal.h is regenerated to
include the new public headers, and callers include the header of the scan they
use.

Why

table_scan.cc held the planning logic of every scan type next to the builder
and the task types, close to 1,000 lines, and each new planning feature grows
it further. One file per scan keeps each scan's planning logic in one place
and the shared scan machinery in table_scan.

Behavior change

iceberg/table_scan.h no longer declares DataTableScan,
IncrementalAppendScan or IncrementalChangelogScan. Code that uses them
beyond the forward declarations in iceberg/type_fwd.h, for example to call
Build() and PlanFiles(), must include iceberg/data_table_scan.h,
iceberg/incremental_append_scan.h or iceberg/incremental_changelog_scan.h.

Testing

scan_test passes, and cpp20_compatibility_test builds with the regenerated
public header list.

🤖 Generated with Claude Code

Move DataTableScan, IncrementalAppendScan and IncrementalChangelogScan
into data_table_scan.{h,cc}, incremental_append_scan.{h,cc} and
incremental_changelog_scan.{h,cc}. table_scan.{h,cc} keep TableScan,
IncrementalScan, TableScanBuilder, the scan task types and
TableScanContext.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 10, 2026 09:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The refactor consistently relocates implementations, updates consumers and build inputs, and introduces no apparent behavioral defects.

0 open findings

What changed in this PR

Splits concrete table-scan implementations into dedicated files while retaining shared scan infrastructure in table_scan.

Changes:

  • Adds separate headers and sources for data, incremental append, and changelog scans.
  • Updates build configuration, public-header compatibility coverage, and includes.
  • Keeps shared builder logic and explicit template instantiations in table_scan.cc.
File Description
src/​iceberg/​data_table_scan.h Declares DataTableScan.
src/​iceberg/​data_table_scan.cc Implements data-scan planning and reporting.
src/​iceberg/​incremental_append_scan.h Declares incremental append scans.
src/​iceberg/​incremental_append_scan.cc Implements incremental append planning.
src/​iceberg/​incremental_changelog_scan.h Declares incremental changelog scans.
src/​iceberg/​incremental_changelog_scan.cc Implements changelog planning.
src/​iceberg/​table_scan.h Retains shared scan APIs.
src/​iceberg/​table_scan.cc Retains shared logic and template instantiations.
src/​iceberg/​table.cc Includes concrete scan definitions.
src/​iceberg/​CMakeLists.txt Builds the new sources.
src/​iceberg/​cpp20_compatibility_internal.h Covers the new public headers.
src/​iceberg/​test/​table_scan_test.cc Includes the data-scan header.
src/​iceberg/​test/​scan_planning_metrics_test.cc Includes the data-scan header.
src/​iceberg/​test/​incremental_append_scan_test.cc Includes the append-scan header.
src/​iceberg/​test/​incremental_changelog_scan_test.cc Includes the changelog-scan header.
example/​demo_example.cc Includes the concrete data-scan API.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@manuzhang
manuzhang requested review from wgtmac and zhjwpku October 10, 2026 09:56

@zhjwpku zhjwpku 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.

+1

@wgtmac wgtmac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure if it is worth adding a new scan subdirectory for this but this is unrelated to this PR.

@wgtmac
wgtmac merged commit c712948 into apache:main Oct 11, 2026
15 checks passed
@manuzhang

Copy link
Copy Markdown
Member Author

Agreed. The file list under src/iceberg is getting too long.

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.

4 participants