11use arrow:: array:: {
2- Array , ArrayData , BinaryArray , BooleanArray , Date32Array , Decimal128Array , Float32Array ,
3- Float64Array , Int16Array , Int32Array , Int64Array , ListArray , MapArray , StringArray ,
4- StructArray , Time64MicrosecondArray , TimestampMicrosecondArray , UInt32Array ,
2+ Array , ArrayData , BinaryArray , BooleanArray , Date32Array , Decimal128Array ,
3+ FixedSizeBinaryArray , Float32Array , Float64Array , Int16Array , Int32Array , Int64Array ,
4+ ListArray , MapArray , StringArray , StructArray , Time64MicrosecondArray ,
5+ TimestampMicrosecondArray , UInt32Array ,
56} ;
67use arrow_schema:: { DataType , TimeUnit } ;
78use context:: ArrowToPgAttributeContext ;
89use pgrx:: {
910 datum:: { Date , Time , TimeWithTimeZone , Timestamp , TimestampWithTimeZone } ,
10- pg_sys:: { Datum , Oid , CHAROID , TEXTOID , TIMEOID } ,
11+ pg_sys:: { Datum , Oid , CHAROID , JSONBOID , JSONOID , TEXTOID , TIMEOID , UUIDOID } ,
1112 prelude:: PgHeapTuple ,
12- AllocatedByRust , AnyNumeric , IntoDatum ,
13+ AllocatedByRust , AnyNumeric , IntoDatum , Json , JsonB , Uuid ,
1314} ;
1415
1516use crate :: {
@@ -37,6 +38,8 @@ pub(crate) mod geometry;
3738pub ( crate ) mod int2;
3839pub ( crate ) mod int4;
3940pub ( crate ) mod int8;
41+ pub ( crate ) mod json;
42+ pub ( crate ) mod jsonb;
4043pub ( crate ) mod map;
4144pub ( crate ) mod numeric;
4245pub ( crate ) mod oid;
@@ -45,6 +48,7 @@ pub(crate) mod time;
4548pub ( crate ) mod timestamp;
4649pub ( crate ) mod timestamptz;
4750pub ( crate ) mod timetz;
51+ pub ( crate ) mod uuid;
4852
4953pub ( crate ) trait ArrowArrayToPgType < T : IntoDatum > : From < ArrayData > {
5054 fn to_pg_type ( self , context : & ArrowToPgAttributeContext ) -> Option < T > ;
@@ -102,6 +106,10 @@ fn to_pg_nonarray_datum(
102106 to_pg_datum ! ( StringArray , i8 , primitive_array, attribute_context)
103107 } else if attribute_context. typoid ( ) == TEXTOID {
104108 to_pg_datum ! ( StringArray , String , primitive_array, attribute_context)
109+ } else if attribute_context. typoid ( ) == JSONOID {
110+ to_pg_datum ! ( StringArray , Json , primitive_array, attribute_context)
111+ } else if attribute_context. typoid ( ) == JSONBOID {
112+ to_pg_datum ! ( StringArray , JsonB , primitive_array, attribute_context)
105113 } else {
106114 reset_fallback_to_text_context (
107115 attribute_context. typoid ( ) ,
@@ -123,6 +131,14 @@ fn to_pg_nonarray_datum(
123131 to_pg_datum ! ( BinaryArray , Vec <u8 >, primitive_array, attribute_context)
124132 }
125133 }
134+ DataType :: FixedSizeBinary ( 16 ) if attribute_context. typoid ( ) == UUIDOID => {
135+ to_pg_datum ! (
136+ FixedSizeBinaryArray ,
137+ Uuid ,
138+ primitive_array,
139+ attribute_context
140+ )
141+ }
126142 DataType :: Decimal128 ( _, _) => {
127143 to_pg_datum ! (
128144 Decimal128Array ,
@@ -232,6 +248,10 @@ fn to_pg_array_datum(
232248 list_array,
233249 element_context
234250 )
251+ } else if element_context. typoid ( ) == JSONOID {
252+ to_pg_datum ! ( StringArray , Vec <Option <Json >>, list_array, element_context)
253+ } else if element_context. typoid ( ) == JSONBOID {
254+ to_pg_datum ! ( StringArray , Vec <Option <JsonB >>, list_array, element_context)
235255 } else {
236256 reset_fallback_to_text_context ( element_context. typoid ( ) , element_context. typmod ( ) ) ;
237257
@@ -260,6 +280,14 @@ fn to_pg_array_datum(
260280 )
261281 }
262282 }
283+ DataType :: FixedSizeBinary ( 16 ) if element_context. typoid ( ) == UUIDOID => {
284+ to_pg_datum ! (
285+ FixedSizeBinaryArray ,
286+ Vec <Option <Uuid >>,
287+ list_array,
288+ element_context
289+ )
290+ }
263291 DataType :: Decimal128 ( _, _) => {
264292 to_pg_datum ! (
265293 Decimal128Array ,
0 commit comments