Skip to content

Commit

Permalink
fix memory problem with FallbackToTextContext during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aykut-bozkurt committed Aug 18, 2024
1 parent 7f1ddf6 commit 1bcc0dd
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 131 deletions.
10 changes: 3 additions & 7 deletions src/arrow_parquet/arrow_to_pg/fallback_to_text.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
use arrow::array::{Array, StringArray};

use crate::type_compat::fallback_to_text::{reset_fallback_to_text_context, FallbackToText};
use crate::type_compat::fallback_to_text::FallbackToText;

use super::{ArrowArrayToPgType, ArrowToPgPerAttributeContext};

// Text representation of any type
impl ArrowArrayToPgType<'_, StringArray, FallbackToText> for FallbackToText {
fn to_pg_type(
arr: StringArray,
context: ArrowToPgPerAttributeContext<'_>,
_context: ArrowToPgPerAttributeContext<'_>,
) -> Option<FallbackToText> {
reset_fallback_to_text_context(context.typoid, context.typmod);

if arr.is_null(0) {
None
} else {
Expand All @@ -28,10 +26,8 @@ impl ArrowArrayToPgType<'_, StringArray, Vec<Option<FallbackToText>>>
{
fn to_pg_type(
arr: StringArray,
context: ArrowToPgPerAttributeContext<'_>,
_context: ArrowToPgPerAttributeContext<'_>,
) -> Option<Vec<Option<FallbackToText>>> {
reset_fallback_to_text_context(context.typoid, context.typmod);

let mut vals = vec![];
for val in arr.iter() {
let val = val.map(|val| FallbackToText(val.to_string()));
Expand Down
Loading

0 comments on commit 1bcc0dd

Please sign in to comment.