diff --git a/src/main.rs b/src/main.rs index c3e61b0..479953e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,7 +54,7 @@ async fn main() -> Result<(), anyhow::Error> { RecordBatchWriter::for_table(&table).expect("Failed to make RecordBatchWriter"); let records = fetch_readings(); - let batch = convert_to_batch(&records); + let batch = convert_to_batch(&table, &records); writer.write(batch).await?; @@ -160,10 +160,14 @@ fn fetch_readings() -> Vec { * transformation is quite tricky in Rust, whereas in Python or another loosely * typed language it might be simpler. */ -fn convert_to_batch(records: &Vec) -> RecordBatch { - let schema = WeatherRecord::schema(); - let arrow_schema = >::try_from(&schema) - .expect("Failed to convert schema tro ArrowSchema"); +fn convert_to_batch(table: &DeltaTable, records: &Vec) -> RecordBatch { + let metadata = table + .get_metadata() + .expect("Failed to get metadata for the table"); + let arrow_schema = >::try_from( + &metadata.schema.clone(), + ) + .expect("Failed to convert to arrow schema"); let arrow_schema_ref = Arc::new(arrow_schema); let mut ts = vec![];