Skip to content

Commit 25f0918

Browse files
committed
allow overriding default and validity strategy
Signed-off-by: Andrew Duffy <[email protected]>
1 parent b20d9e8 commit 25f0918

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

vortex-layout/src/layouts/table.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@ impl TableStrategy {
144144
}
145145
self
146146
}
147+
148+
/// Override the default strategy for leaf columns that don't have overrides.
149+
pub fn with_default_strategy(mut self, default: Arc<dyn LayoutStrategy>) -> Self {
150+
self.fallback = default;
151+
self
152+
}
153+
154+
/// Override the strategy for compressing struct validity at all levels of the schema tree.
155+
pub fn with_validity_strategy(mut self, validity: Arc<dyn LayoutStrategy>) -> Self {
156+
self.validity = validity;
157+
self
158+
}
147159
}
148160

149161
impl TableStrategy {
@@ -169,6 +181,11 @@ impl TableStrategy {
169181
}
170182

171183
fn validate_path(&self, path: FieldPath) -> FieldPath {
184+
assert!(
185+
!path.is_root(),
186+
"Do not set override as a root strategy, instead set the default strategy"
187+
);
188+
172189
// Validate that the field path does not conflict with any overrides
173190
// that we've added by overlapping.
174191
for field_path in self.leaf_writers.keys() {
@@ -358,6 +375,7 @@ impl LayoutStrategy for TableStrategy {
358375
mod tests {
359376
use std::sync::Arc;
360377

378+
use vortex_dtype::FieldPath;
361379
use vortex_dtype::field_path;
362380

363381
use crate::layouts::flat::writer::FlatLayoutStrategy;
@@ -376,4 +394,13 @@ mod tests {
376394
// Should panic right here.
377395
let _path = path.with_field_writer(field_path!(a.b), flat);
378396
}
397+
398+
#[test]
399+
#[should_panic(
400+
expected = "Do not set override as a root strategy, instead set the default strategy"
401+
)]
402+
fn test_root_override() {
403+
let _strategy = TableStrategy::default()
404+
.with_field_writer(FieldPath::root(), Arc::new(FlatLayoutStrategy::default()));
405+
}
379406
}

0 commit comments

Comments
 (0)