Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push empty vec on ArrowAssoc when Option is None to fix Postgres _varchar can panic on Option.unwrap #490

Merged
merged 3 commits into from
Apr 18, 2023
Merged
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
18 changes: 12 additions & 6 deletions connectorx/src/destinations/arrow2/arrow_assoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,19 @@ impl ArrowAssoc for Option<Vec<String>> {
}

fn push(builder: &mut Self::Builder, value: Self) {
let value = value.unwrap();
let mut string_array: Vec<Option<String>> = vec![];
for sub_value in value {
string_array.push(Some(sub_value))
}
match value {
Some(value) => {
for sub_value in value {
string_array.push(Some(sub_value))
}

builder.try_push(Some(string_array));
builder.try_push(Some(string_array)).unwrap();
}
None => {
builder.try_push(Some(string_array)).unwrap();
}
};
}

fn field(header: &str) -> Field {
Expand All @@ -474,7 +480,7 @@ impl ArrowAssoc for Vec<String> {
for sub_value in value {
string_array.push(Some(sub_value))
}
builder.try_push(Some(string_array));
builder.try_push(Some(string_array)).unwrap();
}

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