From b29e5d41fae631514bee592c097e0f0390a5a978 Mon Sep 17 00:00:00 2001 From: auyer Date: Tue, 18 Apr 2023 12:20:49 -0300 Subject: [PATCH 1/3] Push empty vec on ArrowAssoc when Option is None --- connectorx/src/destinations/arrow2/arrow_assoc.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/connectorx/src/destinations/arrow2/arrow_assoc.rs b/connectorx/src/destinations/arrow2/arrow_assoc.rs index 313f9aa85..8fe235688 100644 --- a/connectorx/src/destinations/arrow2/arrow_assoc.rs +++ b/connectorx/src/destinations/arrow2/arrow_assoc.rs @@ -448,13 +448,19 @@ impl ArrowAssoc for Option> { } fn push(builder: &mut Self::Builder, value: Self) { - let value = value.unwrap(); let mut string_array: Vec> = vec![]; + 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 { From 34a2c7c2a7c0af2ea96f6b0d69ec92b1a8e25c56 Mon Sep 17 00:00:00 2001 From: auyer Date: Tue, 18 Apr 2023 12:50:54 -0300 Subject: [PATCH 2/3] fix cargo fmt --- connectorx/src/destinations/arrow2/arrow_assoc.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/connectorx/src/destinations/arrow2/arrow_assoc.rs b/connectorx/src/destinations/arrow2/arrow_assoc.rs index 8fe235688..29062cbcc 100644 --- a/connectorx/src/destinations/arrow2/arrow_assoc.rs +++ b/connectorx/src/destinations/arrow2/arrow_assoc.rs @@ -451,9 +451,9 @@ impl ArrowAssoc for Option> { let mut string_array: Vec> = vec![]; match value { Some(value) => { - for sub_value in value { - string_array.push(Some(sub_value)) - } + for sub_value in value { + string_array.push(Some(sub_value)) + } builder.try_push(Some(string_array)).unwrap(); } From 385e602dc2822eb32b10f3c5fa6219fadf88012e Mon Sep 17 00:00:00 2001 From: auyer Date: Tue, 18 Apr 2023 13:12:37 -0300 Subject: [PATCH 3/3] Adds unwrap on try_push for Vec If it fails, the resulting Chunks will have wrong size With unwrap the failure wont be so silent. Failure without unwrap: _read_sql( RuntimeError: Invalid argument error: Chunk require all its arrays to have an equal number of rows --- connectorx/src/destinations/arrow2/arrow_assoc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectorx/src/destinations/arrow2/arrow_assoc.rs b/connectorx/src/destinations/arrow2/arrow_assoc.rs index 29062cbcc..021b77ffe 100644 --- a/connectorx/src/destinations/arrow2/arrow_assoc.rs +++ b/connectorx/src/destinations/arrow2/arrow_assoc.rs @@ -480,7 +480,7 @@ impl ArrowAssoc for Vec { 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 {