Skip to content

Commit

Permalink
Introduce a test to make sure tilde paths work properly
Browse files Browse the repository at this point in the history
This test fails on main but passes in this branch because the URL
handling logic introduced properly encodes file URLs. No need for
object_store updates here

Fixes delta-io#1806
  • Loading branch information
rtyler committed Jan 3, 2024
1 parent 56a2f8f commit 264adfa
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions crates/deltalake-core/src/writer/record_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,4 +590,33 @@ mod tests {
assert_eq!(ref_batch, result.record_batch);
}
}

/// Validates <https://github.com/delta-io/delta-rs/issues/1806>
#[tokio::test]
async fn test_write_tilde() {
use crate::operations::create::CreateBuilder;
let table_schema = crate::writer::test_utils::get_delta_schema();
let partition_cols = vec!["modified".to_string(), "id".to_string()];
let table_dir = tempfile::Builder::new()
.prefix("example~with~tilde")
.tempdir()
.unwrap();
let table_path = table_dir.path();

let table = CreateBuilder::new()
.with_location(table_path.to_str().unwrap())
.with_table_name("test-table")
.with_comment("A table for running tests")
.with_columns(table_schema.fields().clone())
.with_partition_columns(partition_cols)
.await
.unwrap();

let batch = get_record_batch(None, false);
let mut writer = RecordBatchWriter::for_table(&table).unwrap();

writer.write(batch).await.unwrap();
let adds = writer.flush().await.unwrap();
assert_eq!(adds.len(), 4);
}
}

0 comments on commit 264adfa

Please sign in to comment.