Skip to content

Commit

Permalink
add test to cover null cases
Browse files Browse the repository at this point in the history
  • Loading branch information
y-f-u committed May 24, 2024
1 parent 86b6b44 commit 7148624
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/vtab/arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ mod test {
db.register_table_function::<ArrowVTab>("arrow")?;

// Roundtrip a record batch from Rust to DuckDB and back to Rust
let schema = Schema::new(vec![Field::new("a", input_array.data_type().clone(), false)]);
let schema = Schema::new(vec![Field::new("a", input_array.data_type().clone(), true)]);

let rb = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(input_array.clone())])?;
let param = arrow_recordbatch_to_query_params(rb);
Expand Down Expand Up @@ -760,6 +760,22 @@ mod test {
Ok(())
}

#[test]
fn test_primitive_roundtrip_contains_nulls() -> Result<(), Box<dyn Error>> {
let mut builder = arrow::array::PrimitiveBuilder::<arrow::datatypes::Int32Type>::new();
builder.append_value(1);
builder.append_null();
builder.append_value(3);
builder.append_null();
builder.append_null();
builder.append_value(6);
let array = builder.finish();

check_rust_primitive_array_roundtrip(array.clone(), array)?;

Ok(())
}

#[test]
fn test_timestamp_roundtrip() -> Result<(), Box<dyn Error>> {
check_rust_primitive_array_roundtrip(Int32Array::from(vec![1, 2, 3]), Int32Array::from(vec![1, 2, 3]))?;
Expand Down

0 comments on commit 7148624

Please sign in to comment.