Skip to content

Commit 79d6cb7

Browse files
authored
Merge pull request #490 from auyer/fix/array_panic_on_none
Push empty vec on ArrowAssoc when Option is None to fix Postgres _varchar can panic on Option.unwrap
2 parents c0b18d9 + 385e602 commit 79d6cb7

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

connectorx/src/destinations/arrow2/arrow_assoc.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,13 +448,19 @@ impl ArrowAssoc for Option<Vec<String>> {
448448
}
449449

450450
fn push(builder: &mut Self::Builder, value: Self) {
451-
let value = value.unwrap();
452451
let mut string_array: Vec<Option<String>> = vec![];
453-
for sub_value in value {
454-
string_array.push(Some(sub_value))
455-
}
452+
match value {
453+
Some(value) => {
454+
for sub_value in value {
455+
string_array.push(Some(sub_value))
456+
}
456457

457-
builder.try_push(Some(string_array));
458+
builder.try_push(Some(string_array)).unwrap();
459+
}
460+
None => {
461+
builder.try_push(Some(string_array)).unwrap();
462+
}
463+
};
458464
}
459465

460466
fn field(header: &str) -> Field {
@@ -474,7 +480,7 @@ impl ArrowAssoc for Vec<String> {
474480
for sub_value in value {
475481
string_array.push(Some(sub_value))
476482
}
477-
builder.try_push(Some(string_array));
483+
builder.try_push(Some(string_array)).unwrap();
478484
}
479485

480486
fn field(header: &str) -> Field {

0 commit comments

Comments
 (0)