Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d862569
Give layout scans a native split and open
gatesn Nov 19, 2026
85bec55
Scan Vortex files on the V2 scan through the Scan API
gatesn Nov 19, 2026
05fd3f3
Expose a file's layout-reader Scan API source on its own
gatesn Nov 19, 2026
ac7cd96
Read plan data sources through the base's segment sources
gatesn Nov 19, 2026
044da4d
Give V2 plan sources a native split and open
gatesn Nov 19, 2026
5a87d7f
Test V2 split and open over reads that pend and multi-chunk parts
gatesn Nov 19, 2026
de0e5c2
Expand deferred plan children rather than open deferred files
gatesn Nov 19, 2026
e468b71
Give layout scans a native split and open
gatesn Nov 19, 2026
540b8cc
Spawn pool splits onto the session runtime
gatesn Nov 19, 2026
b9f7e17
Merge ngates/scan-native-pool into ngates/v2-scan-pool
gatesn Nov 19, 2026
e3e3a74
Drive V1 pool tests on a runtime that runs spawned splits
gatesn Nov 19, 2026
c6602d5
Cut V2 pool parts on layout splits and prune dynamic filters first
gatesn Nov 19, 2026
ad5a9f9
Merge ngates/scan-native-pool into ngates/v2-scan-pool
gatesn Nov 20, 2026
336d042
Merge branch 'ngates/scan-native-pool' of github.com:vortex-data/vort…
gatesn Nov 20, 2026
4a10ff1
Merge branch 'ngates/scan-native-pool' of github.com:vortex-data/vort…
gatesn Nov 20, 2026
20f2cf9
Merge commit '235d5396e9' into ngates/v2-scan-pool
gatesn Nov 20, 2026
f4525fa
Merge commit '3cd0419353' into ngates/v2-scan-pool
gatesn Nov 20, 2026
fb19d83
Bind a request once per (expression, dtype) in each session
gatesn Nov 20, 2026
430626f
Merge ngates/scan-native-pool into ngates/v2-scan-pool
gatesn Nov 20, 2026
bdc7a33
Run DataFusion's Scan API tables on the V2 scan
gatesn Nov 20, 2026
5b0d39e
Run opened V2 plan scans on V2's own driver
gatesn Nov 20, 2026
c738445
Merge ngates/scan-native-pool into ngates/v2-scan-pool
gatesn Nov 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion bench-orchestrator/bench_orchestrator/ci_matrix/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
# Vortex targets name an integration (`file`, `datasource`) and a scan engine (`v1`, `v2`); see
# `BenchmarkTarget`. Declared targets run the file integration on the suite's default engine.
# `ScanCoverage.ALL` adds every other valid combination for the `vortex` format: DataFusion file-v1 and
# datasource-v1 beside file-v2, and DuckDB file-v1 beside file-v2, on V2 suites. Each combination runs
# datasource-v2 and datasource-v1 beside file-v2, and DuckDB file-v1 beside file-v2, on V2 suites. Each combination runs
# as a matrix entry, and so a machine, of its own, so covering them all adds machines, not wall time.


Expand Down Expand Up @@ -108,6 +108,10 @@ def with_all_scans(coverage: Coverage) -> Coverage:
BenchmarkTarget(Engine.DATAFUSION, Format.VORTEX, Integration.FILE, ScanEngine.V1),
"DataFusion, Vortex, file v1",
),
(
BenchmarkTarget(Engine.DATAFUSION, Format.VORTEX, Integration.DATASOURCE, ScanEngine.V2),
"DataFusion, Vortex, datasource v2",
),
(
BenchmarkTarget(Engine.DATAFUSION, Format.VORTEX, Integration.DATASOURCE, ScanEngine.V1),
"DataFusion, Vortex, datasource v1",
Expand Down
9 changes: 1 addition & 8 deletions bench-orchestrator/bench_orchestrator/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ class Benchmark(Enum):
SUPPORTED_SCANS: dict[Engine, dict[Integration, frozenset[ScanEngine]]] = {
Engine.DATAFUSION: {
Integration.FILE: frozenset({ScanEngine.V1, ScanEngine.V2}),
# `VortexTable` reaches only V1: `MultiFileDataSource` opens `LayoutReader`s. V2 needs the V2
# scan behind `split`/`open` (#11626).
Integration.DATASOURCE: frozenset({ScanEngine.V1}),
Integration.DATASOURCE: frozenset({ScanEngine.V1, ScanEngine.V2}),
},
Engine.DUCKDB: {
Integration.FILE: frozenset({ScanEngine.V1, ScanEngine.V2}),
Expand Down Expand Up @@ -168,11 +166,6 @@ def scan_support_error(engine: Engine, integration: Integration, scan: ScanEngin
return "duckdb has no DataSource table function yet, so it has no datasource targets"
return f"{engine.value} has no {integration.value} integration"
if scan is not None and scan not in integrations[integration]:
if engine is Engine.DATAFUSION and integration is Integration.DATASOURCE and scan is ScanEngine.V2:
return (
"datafusion datasource targets run only the v1 scan: MultiFileDataSource opens "
"LayoutReaders, and v2 needs the V2 scan behind split/open (#11626)"
)
return f"{engine.value} {integration.value} targets cannot run the {scan.value} scan"
return None

Expand Down
2 changes: 1 addition & 1 deletion bench-orchestrator/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ def test_parse_targets_json_rejects_unknown_axes() -> None:
(Engine.DATAFUSION, Integration.FILE, ScanEngine.V1, None),
(Engine.DATAFUSION, Integration.FILE, ScanEngine.V2, None),
(Engine.DATAFUSION, Integration.DATASOURCE, ScanEngine.V1, None),
(Engine.DATAFUSION, Integration.DATASOURCE, ScanEngine.V2, None),
(Engine.DUCKDB, Integration.FILE, ScanEngine.V1, None),
(Engine.DUCKDB, Integration.FILE, ScanEngine.V2, None),
(Engine.DATAFUSION, Integration.DATASOURCE, ScanEngine.V2, "datasource targets run only the v1 scan"),
(Engine.DUCKDB, Integration.DATASOURCE, ScanEngine.V1, "duckdb has no DataSource table function yet"),
(Engine.DUCKDB, Integration.DATASOURCE, ScanEngine.V2, "duckdb has no DataSource table function yet"),
],
Expand Down
10 changes: 7 additions & 3 deletions bench-orchestrator/tests/test_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"duckdb-parquet",
"duckdb-vortex",
"datafusion-vortex-file-v1",
"datafusion-vortex-datasource-v2",
"datafusion-vortex-datasource-v1",
"duckdb-vortex-file-v1",
)
Expand All @@ -83,7 +84,7 @@
"tpch-nested-s3",
),
}
SCAN_SUFFIXES = ("datafusion-file-v1", "datafusion-datasource-v1", "duckdb-file-v1")
SCAN_SUFFIXES = ("datafusion-file-v1", "datafusion-datasource-v2", "datafusion-datasource-v1", "duckdb-file-v1")


def _entries(preset: str) -> list[dict[str, object]]:
Expand Down Expand Up @@ -121,6 +122,7 @@ def _group_targets(preset: str) -> dict[str, set[tuple[str, str]]]:
("datafusion", "parquet"),
("datafusion", "vortex [file, v2]"),
("datafusion", "vortex [file, v1]"),
("datafusion", "vortex [datasource, v2]"),
("datafusion", "vortex [datasource, v1]"),
("duckdb", "parquet"),
("duckdb", "vortex [file, v2]"),
Expand Down Expand Up @@ -197,11 +199,11 @@ def test_tpcds_sf100_runs_one_target_per_job() -> None:
entry for entry in _entries("nightly") if str(entry["id"]).startswith("tpcds-") and "-100-" in str(entry["id"])
]

assert len(nightly) == 14
assert len(nightly) == 16
assert all(len(_targets(entry)) == 1 for entry in nightly)
assert {target for entry in nightly for target in _targets(entry)} == ALL_SCANS
s3_keys = [entry["remote_key"] for entry in nightly if "remote_key" in entry]
assert len(s3_keys) == len(set(s3_keys)) == 7
assert len(s3_keys) == len(set(s3_keys)) == 8


def test_nightly_runs_every_scan() -> None:
Expand Down Expand Up @@ -251,6 +253,8 @@ def test_nightly_runs_every_valid_scan() -> None:
)
if not benchmark_id.startswith("tpch-nested"):
expected |= {(engine, "vortex [file, v2]") for engine in engines}
if "datafusion" in engines:
expected.add(("datafusion", "vortex [datasource, v2]"))
assert scans == expected, benchmark_id


Expand Down
28 changes: 16 additions & 12 deletions benchmarks/datafusion-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use vortex::file::multi::MultiFileDataSource;
use vortex::io::filesystem::FileSystemRef;
use vortex::io::object_store::ObjectStoreFileSystem;
use vortex::io::session::RuntimeSessionExt;
use vortex::scan::DataSource as _;
use vortex::scan::DataSourceRef;
use vortex_arrow::ArrowSessionExt;
use vortex_bench::Benchmark;
Expand Down Expand Up @@ -125,8 +124,7 @@ struct Args {
scan_v1: bool,

/// Register Vortex tables through the Scan API (`VortexTable` over a `MultiFileDataSource`)
/// instead of a listing table, whatever `--scan-v1` says. `MultiFileDataSource` runs the V1
/// scan.
/// instead of a listing table. `--scan-v1` still picks the scan the tables run on.
#[arg(long, default_value_t = false, action = clap::ArgAction::Set)]
scan_api: bool,

Expand Down Expand Up @@ -268,7 +266,7 @@ async fn register_benchmark_tables<B: Benchmark + ?Sized>(
scan_api: bool,
) -> anyhow::Result<()> {
if scan_api && matches!(format, Format::OnDiskVortex | Format::VortexCompact) {
register_v2_tables(session, benchmark, format).await
register_scan_api_tables(session, benchmark, format, scan_v2).await
} else {
let benchmark_base = benchmark.data_url().join(&format!("{}/", format.name()))?;
let file_format = format_to_df_format(format, scan_v2)?;
Expand Down Expand Up @@ -304,11 +302,16 @@ async fn register_benchmark_tables<B: Benchmark + ?Sized>(
}
}

/// Register tables using the Scan API path: a `VortexTable` over a `MultiFileDataSource`.
async fn register_v2_tables<B: Benchmark + ?Sized>(
/// Register tables through the Scan API: a `VortexTable` over a `MultiFileDataSource`.
///
/// With `scan_v2`, the table scans its files on the planner-driven scan through
/// [`MultiFileDataSource::build_plan`], whose files open as the scan reaches them. Otherwise it
/// scans them on layout readers through [`MultiFileDataSource::build`].
async fn register_scan_api_tables<B: Benchmark + ?Sized>(
session: &SessionContext,
benchmark: &B,
format: Format,
scan_v2: bool,
) -> anyhow::Result<()> {
let benchmark_base = benchmark.data_url().join(&format!("{}/", format.name()))?;

Expand All @@ -332,13 +335,14 @@ async fn register_v2_tables<B: Benchmark + ?Sized>(
None => format!("*.{}", format.ext()),
};

let multi_ds = MultiFileDataSource::new(SESSION.clone())
.with_glob(glob_pattern, Some(fs))
.build()
.await?;
let builder = MultiFileDataSource::new(SESSION.clone()).with_glob(glob_pattern, Some(fs));
let data_source: DataSourceRef = if scan_v2 {
builder.build_plan().await?
} else {
Arc::new(builder.build().await?)
};

let arrow_schema = Arc::new(SESSION.arrow().to_arrow_schema(multi_ds.dtype())?);
let data_source: DataSourceRef = Arc::new(multi_ds);
let arrow_schema = Arc::new(SESSION.arrow().to_arrow_schema(data_source.dtype())?);

let table_provider = Arc::new(VortexTable::new(data_source, SESSION.clone(), arrow_schema));
session.register_table(table.name, table_provider)?;
Expand Down
122 changes: 115 additions & 7 deletions vortex-file/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,25 @@ use itertools::Itertools;
use vortex_array::ArrayRef;
use vortex_array::dtype::DType;
use vortex_array::dtype::FieldMask;
use vortex_array::expr::BoundExpression;
use vortex_array::expr::Expression;
use vortex_buffer::ByteBuffer;
use vortex_error::VortexResult;
use vortex_layout::LayoutReader;
use vortex_layout::layouts::list::List;
use vortex_layout::scan::layout::LayoutReaderDataSource;
use vortex_layout::scan::metrics::ScanUsage;
use vortex_layout::scan::scan_builder::ScanBuilder;
use vortex_layout::scan::scan_builder::referenced_field_masks;
use vortex_layout::scan::split_by::SplitBy;
use vortex_layout::scan::v2::ScanFile;
use vortex_layout::segments::SegmentSource;
use vortex_layout::segments::UsageSegmentSource;
use vortex_scan::DataSourceRef;
use vortex_scan::prepare::ScanCache;
use vortex_scan::prepare::SegmentLocation;
use vortex_scan::source::PlanChild;
use vortex_scan::source::PlanDataSource;
use vortex_session::VortexSession;
use vortex_utils::aliases::hash_map::HashMap;

Expand Down Expand Up @@ -68,6 +73,29 @@ struct FileScanCache {
plans: ScanCache,
}

/// Whether a layout tree of `dtype` may contain a list layout.
///
/// A list layout only ever holds a [`DType::List`], and the writer only decomposes the lists it
/// reaches through struct fields and list elements. Maps and variants are conservatively assumed
/// to contain one too, since their storage may be laid out as lists.
pub(crate) fn may_contain_list_layout(dtype: &DType) -> bool {
match dtype {
DType::List(..) | DType::Map(..) | DType::Variant(_) => true,
DType::Null
| DType::Bool(_)
| DType::Primitive(..)
| DType::Decimal(..)
| DType::Utf8(_)
| DType::Binary(_) => false,
DType::FixedSizeList(element, ..) => may_contain_list_layout(element),
DType::Struct(fields, _) => fields.fields().any(|field| may_contain_list_layout(&field)),
DType::Union(variants, _) => variants
.variants()
.any(|variant| may_contain_list_layout(&variant)),
DType::Extension(ext) => may_contain_list_layout(ext.storage_dtype()),
}
}

fn layout_reader(
segment_source: Arc<dyn SegmentSource>,
footer: &Footer,
Expand Down Expand Up @@ -114,9 +142,10 @@ impl VortexFile {

/// Enable layout reader and V2 scan caching.
///
/// Repeated calls to [`layout_reader`](Self::layout_reader), [`scan`](Self::scan), and
/// [`data_source`](Self::data_source) will share the same reader tree. Repeated V2 scans of
/// [`scan_file`](Self::scan_file) will share its segment locations and a [`ScanCache`].
/// Repeated calls to [`layout_reader`](Self::layout_reader) and [`scan`](Self::scan), and to
/// [`data_source`](Self::data_source) for a file it scans with the layout reader, will share the
/// same reader tree. Repeated V2 scans of [`scan_file`](Self::scan_file), and so of the plan
/// data sources, will share its segment locations and a [`ScanCache`].
pub fn with_caching(self) -> Self {
let scan_cache = FileScanCache {
locations: self.footer.segment_locations(),
Expand Down Expand Up @@ -245,18 +274,97 @@ impl VortexFile {

/// Create a [`DataSource`](vortex_scan::DataSource) from this file for scanning.
///
/// Wraps the file's layout reader with [`FileStatsLayoutReader`] (when file-level
/// statistics are available) and [`LayoutReaderDataSource`]. Stored footer aggregates are
/// available through the source statistics methods without reading payloads.
/// Scans run on the planner-driven executor, as with
/// [`plan_data_source`](Self::plan_data_source), unless the file has a layout that
/// executor cannot read yet. Such files are scanned on the layout reader instead, as with
/// [`layout_reader_data_source`](Self::layout_reader_data_source). Either way, a scan whose
/// filter the file-level statistics prove false reads nothing, and stored footer aggregates
/// are available through the source statistics methods without reading payloads.
pub fn data_source(&self) -> VortexResult<DataSourceRef> {
let reader = self.layout_reader()?;
if self.planned_scan_supported()? {
return Ok(self.plan_data_source());
}
self.layout_reader_data_source()
}

/// Create a [`DataSource`](vortex_scan::DataSource) that scans this file with its
/// [layout reader](Self::layout_reader), whatever its layouts.
///
/// Use [`data_source`](Self::data_source) unless the layout reader is required, for example
/// to compare it with [`plan_data_source`](Self::plan_data_source). Stored footer aggregates
/// are available through the source statistics methods without reading payloads.
pub fn layout_reader_data_source(&self) -> VortexResult<DataSourceRef> {
let reader = self.layout_reader()?;
Ok(Arc::new(FileDataSource::new(
LayoutReaderDataSource::new(reader, self.session.clone()),
self.file_stats().cloned(),
)))
}

/// Whether the planner-driven executor can scan this file, which
/// [`data_source`](Self::data_source) uses to choose its executor.
///
/// The planner-driven executor cannot read list layouts yet (tracked with making it the
/// default in #11502), so files that contain one are scanned by the layout reader instead. The
/// layout tree is only walked when the file's dtype could hold a list layout.
pub(crate) fn planned_scan_supported(&self) -> VortexResult<bool> {
if !may_contain_list_layout(self.dtype()) {
return Ok(true);
}
for layout in self.footer.layout().depth_first_traversal() {
if layout?.is::<List>() {
return Ok(false);
}
}
Ok(true)
}

/// Create a [`DataSource`](vortex_scan::DataSource) from this file whose scans run on the
/// planner-driven executor.
///
/// The source is a [`PlanDataSource`] over [`plan_file`](Self::plan_child): hosts read its
/// scans through native `split` and `open`, or through one partition covering the requested
/// rows, which runs it with [`ScanDriver`](crate::v2::ScanDriver) from
/// [`Partition::execute`](vortex_scan::Partition::execute). Every scan of the source shares
/// one [`ScanCache`]: the file's, with [caching](Self::with_caching), or else one of its own.
/// A scan whose filter the file-level statistics prove false reads nothing. Stored footer
/// aggregates are available through the source statistics methods. Opening the source reads
/// nothing and builds no layout reader.
pub fn plan_data_source(&self) -> DataSourceRef {
let source = PlanDataSource::from_child(self.session.clone(), self.plan_child());
Arc::new(FileDataSource::new(source, self.file_stats().cloned()))
}

/// This file as a child of a [`PlanDataSource`]: its V2 scan input, row count, and a pruner
/// that skips scans whose filter the file-level statistics prove false.
///
/// An opened scan of the child cuts its work on the file's layout splits over the fields it
/// reads, as a V1 scan of the same fields does.
pub fn plan_child(&self) -> PlanChild {
let splitter = {
let file = self.clone();
Arc::new(
move |projection: &BoundExpression, filter: Option<&BoundExpression>| {
SplitBy::default().splits(
file.layout_reader()?.as_ref(),
&(0..file.row_count()),
&referenced_field_masks(projection, filter)?,
)
},
)
};
let file = PlanChild::new(self.scan_file().into())
.with_row_count(self.row_count())
.with_splitter(splitter);
let Some(statistics) = self.file_stats().cloned() else {
return file;
};
let (row_count, session) = (self.row_count(), self.session.clone());
file.with_pruner(Arc::new(move |filter| {
is_falsified_by_file_stats(filter, row_count, &statistics, &session)
}))
}

/// Initiate a scan of the file, returning a builder for projection, filtering, selection, and
/// execution options.
pub fn scan(&self) -> VortexResult<ScanBuilder<ArrayRef>> {
Expand Down
2 changes: 2 additions & 0 deletions vortex-file/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ pub mod flatbuffers;
mod footer;
pub mod multi;
mod open;
#[cfg(test)]
mod plan_tests;
mod pruning;
/// Segment sources, caches, and sinks used by file readers and writers.
pub mod segments;
Expand Down
Loading
Loading