Skip to content

Commit

Permalink
feat: _text (#1645)
Browse files Browse the repository at this point in the history
Signed-off-by: Chloe Kim <[email protected]>
Co-authored-by: Dario Pizzamiglio <[email protected]>
  • Loading branch information
Chloe Kim and mediuminvader authored Jun 15, 2023
1 parent d7bcba6 commit 2f9b84b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion dozer-ingestion/src/connectors/postgres/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,14 @@ pub fn postgres_type_to_dozer_type(column_type: Type) -> Result<FieldType, Postg
Type::BYTEA => 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())),
Expand Down Expand Up @@ -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<Vec<String>, _> = 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 => {
Expand Down

0 comments on commit 2f9b84b

Please sign in to comment.