Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/arrow_parquet/pg_to_arrow/uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ impl PgTypeToArrowArray<Uuid> for Vec<Option<Uuid>> {
.iter()
.map(|uuid| uuid.as_ref().map(|uuid| uuid.as_bytes().as_slice()))
.collect::<Vec<_>>();
let uuid_array = FixedSizeBinaryArray::from(uuids);
let uuid_array =
FixedSizeBinaryArray::try_from_sparse_iter_with_size(uuids.into_iter(), 16)
.expect("Failed to create FixedSizeBinaryArray from Uuid");
Arc::new(uuid_array)
}
}
Expand All @@ -32,7 +34,9 @@ impl PgTypeToArrowArray<Uuid> for Vec<Option<Vec<Option<Uuid>>>> {
.map(|uuid| uuid.as_ref().map(|uuid| uuid.as_bytes().as_slice()))
.collect::<Vec<_>>();

let uuid_array = FixedSizeBinaryArray::from(pg_array);
let uuid_array =
FixedSizeBinaryArray::try_from_sparse_iter_with_size(pg_array.into_iter(), 16)
.expect("Failed to create FixedSizeBinaryArray from Uuid");

let list_array = ListArray::new(
element_context.field(),
Expand Down
14 changes: 14 additions & 0 deletions src/pgrx_tests/copy_type_roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,20 @@ mod tests {
test_table.assert_expected_and_result_rows();
}

#[pg_test]
fn test_all_null_uuid() {
let test_table = TestTable::<Uuid>::new("uuid".into());
test_table.insert("INSERT INTO test_expected (a) VALUES (null), (null);");
test_table.assert_expected_and_result_rows();
}

#[pg_test]
fn test_all_null_uuid_array() {
let test_table = TestTable::<Vec<Option<Uuid>>>::new("uuid[]".into());
test_table.insert("INSERT INTO test_expected (a) VALUES (array[null]::uuid[]);");
test_table.assert_expected_and_result_rows();
}

#[pg_test]
fn test_json() {
let test_table = TestTable::<Json>::new("json".into()).with_order_by_col("a->>'a'".into());
Expand Down