Skip to content

Commit 60c1227

Browse files
authored
Assortment of VortexSource improvements and fixes (#8718)
## Rationale for this change General improvements of the `FileSource`-based Apache DataFusion integration. ## What changes are included in this PR? 1. DF metrics are in use, so make better use of them both on reads and writes, which is a step towards having the same default observability that `ParquetSource` provides. 2. Fix a subtle issue where a dynamic expression only references partition literals, which we currently don't handle correctly. 3. Drop `batch_size` from the source, by default DataFusion splits the data coming out of `DataScanExec` nodes. 4. Make sure we keep schema and field metadata through all the projections paths. ## What APIs are changed? Are there any user-facing changes? More metrics will be reported in DF, and batch size needs to be done through the `DataSourceExec` and `FileScanConfig` level. --------- Signed-off-by: Adam Gutglick <adam@spiraldb.com>
1 parent c981534 commit 60c1227

4 files changed

Lines changed: 363 additions & 78 deletions

File tree

vortex-datafusion/src/convert/schema.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ pub fn calculate_physical_schema(
5656
})
5757
.collect::<DFResult<Vec<_>>>()?;
5858

59-
Ok(Schema::new(fields))
59+
Ok(Schema::new_with_metadata(
60+
fields,
61+
reference_logical_schema.metadata().clone(),
62+
))
6063
}
6164

6265
/// Calculate the physical Arrow type for a field, preferring the logical type when the
@@ -246,6 +249,32 @@ mod tests {
246249
);
247250
}
248251

252+
#[test]
253+
fn test_schema_metadata_preserved() -> DFResult<()> {
254+
let logical_schema = Schema::new_with_metadata(
255+
vec![Field::new("col", DataType::Int32, false)],
256+
[("table".to_string(), "metadata".to_string())]
257+
.into_iter()
258+
.collect(),
259+
);
260+
let dtype = DType::Struct(
261+
StructFields::from_iter([(
262+
"col",
263+
DType::Primitive(PType::I32, Nullability::NonNullable),
264+
)]),
265+
Nullability::NonNullable,
266+
);
267+
268+
let physical_schema =
269+
calculate_physical_schema(&dtype, &logical_schema, &ArrowSession::default())?;
270+
271+
assert_eq!(
272+
physical_schema.metadata().get("table"),
273+
Some(&"metadata".to_string())
274+
);
275+
Ok(())
276+
}
277+
249278
#[test]
250279
fn test_utf8_variants_preserved() {
251280
// Non-view string types become view types after roundtrip through DType,

0 commit comments

Comments
 (0)