From 2f9b84b103e5753c9706e1a766db55776cc7f665 Mon Sep 17 00:00:00 2001 From: Chloe Kim Date: Thu, 15 Jun 2023 23:14:20 +0800 Subject: [PATCH] feat: _text (#1645) Signed-off-by: Chloe Kim Co-authored-by: Dario Pizzamiglio <1150680+mediuminvader@users.noreply.github.com> --- .../src/connectors/postgres/helper.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/dozer-ingestion/src/connectors/postgres/helper.rs b/dozer-ingestion/src/connectors/postgres/helper.rs index a7d6cc30fb..12a6466f79 100644 --- a/dozer-ingestion/src/connectors/postgres/helper.rs +++ b/dozer-ingestion/src/connectors/postgres/helper.rs @@ -125,7 +125,14 @@ pub fn postgres_type_to_dozer_type(column_type: Type) -> Result Ok(FieldType::Binary), Type::TIMESTAMP | Type::TIMESTAMPTZ => Ok(FieldType::Timestamp), Type::NUMERIC => Ok(FieldType::Decimal), - Type::JSONB | Type::JSON | Type::JSONB_ARRAY | Type::JSON_ARRAY => Ok(FieldType::Json), + Type::JSONB + | Type::JSON + | Type::JSONB_ARRAY + | Type::JSON_ARRAY + | Type::TEXT_ARRAY + | Type::CHAR_ARRAY + | Type::VARCHAR_ARRAY + | Type::BPCHAR_ARRAY => Ok(FieldType::Json), Type::DATE => Ok(FieldType::Date), Type::POINT => Ok(FieldType::Point), _ => Err(ColumnTypeNotSupported(column_type.name().to_string())), @@ -194,6 +201,16 @@ pub fn value_to_field( Ok(Field::Json(JsonValue::Array(lst))) }) } + &Type::CHAR_ARRAY | &Type::TEXT_ARRAY | &Type::VARCHAR_ARRAY | &Type::BPCHAR_ARRAY => { + let value: Result, _> = row.try_get(idx); + value.map_or_else(handle_error, |val| { + let mut lst = vec![]; + for v in val { + lst.push(JsonValue::String(v)); + } + Ok(Field::Json(JsonValue::Array(lst))) + }) + } &Type::POINT => convert_row_value_to_field!(row, idx, GeoPoint), // &Type::UUID => convert_row_value_to_field!(row, idx, Uuid), &Type::UUID => {