Repository navigation
feat(scan): Support split and parallel scans - Part-1: validated FileScanTask byte ranges - #976
Merged
Conversation
kamcheungting-db
marked this pull request as ready for review
October 1, 2026 09:05
kamcheungting-db
force-pushed
the
feat/file-scan-task-ranges
branch
from
October 4, 2026 01:59
2014413 to
cce43f7
Compare
Preserve start and length in core and REST JSON, and reject partial reads until the reader can honor ranges.
kamcheungting-db
force-pushed
the
feat/file-scan-task-ranges
branch
from
October 12, 2026 00:03
cf714b3 to
3bae712
Compare
Co-authored-by: Isaac <no-reply@databricks.com>
zhjwpku
reviewed
Oct 12, 2026
Co-authored-by: Isaac <no-reply@databricks.com>
zhjwpku
approved these changes
Oct 13, 2026
zhjwpku
left a comment
Member
There was a problem hiding this comment.
Other than the two minor issues, LGTM.
wgtmac
reviewed
Oct 14, 2026
A shared DataFile's size may change after MakeSplit, so ToJson could emit a range that FileScanTaskFromJson rejects. Revalidate the range before serializing, matching the REST serializer. Co-authored-by: Isaac <no-reply@databricks.com>
wgtmac
approved these changes
Oct 15, 2026
| int64_t start; | ||
| int64_t length; | ||
| // Size when the range was validated. Always positive, so safe to divide by. | ||
| int64_t file_size; |
Member
There was a problem hiding this comment.
IMHO, this file_size field is duplicated with that in the data_file. Can we remove this to avoid duplication and possible inconsistency in the future?
wgtmac
pushed a commit
that referenced
this pull request
Nov 22, 2026
… group planning (#1113) ## What this PR does Adds task-group planning for parallel scans, on top of the byte ranges from #976 and the range-aware Parquet reads from #1002: - `DataTableScan::PlanTasksStream()` — lazy, fallible stream of `FileScanTaskGroup` - `DataTableScan::PlanTasks()` — the same, collected into a vector Eligible Parquet files are split into byte ranges, and the tasks are packed into groups of roughly `read.split.target-size` bytes. ## How it works ``` PlanFilesStream() | v Whole Parquet file larger than target? -- no --> keep task as is | yes v Valid manifest split_offsets? | yes | no v v merge intervals fixed-size byte ranges toward target (shorter final range if needed) | | +---------+----------+ v pack tasks into groups | v FileScanTaskGroup stream ``` **Packing** — follows Java Iceberg’s first-fit and eviction rules: - task weight = `max(range bytes + delete content bytes, (1 + delete files) * open-file-cost)`; a deletion vector counts its blob size, not its container file size - a task joins the first open group that still fits - at most `planning-lookback` groups stay open; when a new one opens, the largest open group is closed first - at most 1,024 tasks per group; a task heavier than the target becomes its own group **Files that stay whole:** files at or below the target size, non-Parquet files, and Parquet files whose valid manifest offsets yield only one range. ## Settings | Property | Default | Resolves from | |---|---|---| | `read.split.target-size` | 128 MB | scan option > table property > default | | `read.split.planning-lookback` | 10 | same | | `read.split.open-file-cost` | 4 MB | same | Malformed or invalid values fail planning before any planning work starts. ## Stream behavior Single pass, lazy, owns the underlying task stream and its metrics, and can outlive the scan. An executor set with `PlanWith()` is borrowed and must stay alive until the group stream is destroyed. Destroying the stream mid-consumption releases all planning resources. The stream retains the current file’s remaining splits across calls to `Next()`. Splitting requires no data-file I/O or Parquet bundle registration. ## Tests - `table_test` (core-only, includes `ScanTaskPlanningTest`): split coverage and merging, delete files and residual filters carried into every split, mixed Parquet/Avro groups, the Java weight formula, group packing (first fit, lookback, 1,024 cap, oversized singleton), settings precedence and errors, incremental consumption, early destruction. - Bundled `scan_test`, across manifest format versions: split offsets used with no footer read (the file path does not exist), fixed-size ranges for missing or invalid offsets, files at or below target stay whole, every row read exactly once across splits, scan option beats table property, no-snapshot scans, delete files carried into every split. `pre-commit` is clean. ## Related Part 1 #976 · Part 2a #1002 · Part 2b #1062 · Part 2c #1065. The bounded parallel reader and end-to-end validation follow in later parts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow
FileScanTaskto represent a validated half-open byte range instead of always representing an entire data file. Standalone and REST task JSON now preserve those ranges.FileScanTask::MakeSplit,start,length, andis_splitFileScanTaskReaderuntil range-aware file reading is implementedRange behavior
startis a byte offset, andlengthis the number of bytes to scan, not the ending offset. For a 10-byte file, these two tasks cover the file without overlap:{"start": 0, "length": 4} {"start": 4, "length": 6}A full-file range is canonicalized to the existing whole-file task representation. A zero-length range is valid only for a zero-byte file:
start=0, length=0.Both C++ JSON parsers return
JsonParseErrorfor invalid supplied ranges. Standalone JSON requires both fields. REST JSON defaults to the whole file only when both fields are absent.C++ and Java comparison
Valid standalone ranges behave the same in C++ and Java. C++ additionally validates range bounds. REST range transport differs: Java currently ignores these fields and creates whole-file tasks.
The tables assume a 10-byte data file and otherwise valid JSON, except where a zero-byte file is explicitly mentioned. Java behavior was checked at commit
db43b88.Standalone task JSON
This is the self-contained format with embedded schema, partition spec, and delete files.
startandlengthnull1.0), or integer outside signed 64-bit range(0,10)(0,9)or(4,6)(1,10)(0,0)for a zero-byte fileAll C++ rejections above return
JsonParseError. Error wording can differ from Java. Java accepting a range during parsing does not establish that the range is valid or readable.Sources: Java
FileScanTaskParser,BaseFileScanTask.SplitScanTask, andJsonUtil.getLong.REST scan-task JSON
This format uses external partition specs and references a shared delete-file list.
startandlength(0,10)(0,10)(4,6)All C++ rejections above return
JsonParseError. The current Java REST parser and RESTFileScanTaskschema do not define range handling. These fields are therefore a C++ extension, and this PR does not establish interoperable REST split transport with Java. Sending two partial tasks for the same file to that Java implementation can turn them into two whole-file tasks.Sources: Java
RESTFileScanTaskParserand the RESTFileScanTaskschema.Scope
This PR models, validates, and transports byte ranges. It does not enable partial file reads yet. Returning
NotSupportedprevents a split task from silently rereading the entire file; range-aware format readers will follow separately.Testing
ctest --test-dir build-clang -R "^(scan_test|data_test|rest_catalog_test)$" --output-on-failurejson_serde_testandrest_catalog_testpre-commitpassed on the five changed JSON source/header/test filesgit diff --checkpassed