@@ -476,14 +476,110 @@ impl_produce!(
476476 & ' r str ,
477477 Vec <u8 >,
478478 NaiveTime ,
479- NaiveDateTime ,
480- DateTime <Utc >,
481- NaiveDate ,
479+ // NaiveDateTime,
480+ // DateTime<Utc>,
481+ // NaiveDate,
482482 Uuid ,
483483 Value ,
484484 Vec <String >,
485485) ;
486486
487+ impl < ' r , ' a > Produce < ' r , NaiveDateTime > for PostgresBinarySourcePartitionParser < ' a > {
488+ type Error = PostgresSourceError ;
489+
490+ #[ throws( PostgresSourceError ) ]
491+ fn produce ( & ' r mut self ) -> NaiveDateTime {
492+ let ( ridx, cidx) = self . next_loc ( ) ?;
493+ let row = & self . rowbuf [ ridx] ;
494+ let val = row. try_get ( cidx) ?;
495+ match val {
496+ postgres:: types:: Timestamp :: PosInfinity => NaiveDateTime :: MAX ,
497+ postgres:: types:: Timestamp :: NegInfinity => NaiveDateTime :: MIN ,
498+ postgres:: types:: Timestamp :: Value ( t) => t,
499+ }
500+ }
501+ }
502+
503+ impl < ' r , ' a > Produce < ' r , Option < NaiveDateTime > > for PostgresBinarySourcePartitionParser < ' a > {
504+ type Error = PostgresSourceError ;
505+
506+ #[ throws( PostgresSourceError ) ]
507+ fn produce ( & ' r mut self ) -> Option < NaiveDateTime > {
508+ let ( ridx, cidx) = self . next_loc ( ) ?;
509+ let row = & self . rowbuf [ ridx] ;
510+ let val = row. try_get ( cidx) ?;
511+ match val {
512+ postgres:: types:: Timestamp :: PosInfinity => Some ( NaiveDateTime :: MAX ) ,
513+ postgres:: types:: Timestamp :: NegInfinity => Some ( NaiveDateTime :: MIN ) ,
514+ postgres:: types:: Timestamp :: Value ( t) => t,
515+ }
516+ }
517+ }
518+
519+ impl < ' r , ' a > Produce < ' r , DateTime < Utc > > for PostgresBinarySourcePartitionParser < ' a > {
520+ type Error = PostgresSourceError ;
521+
522+ #[ throws( PostgresSourceError ) ]
523+ fn produce ( & ' r mut self ) -> DateTime < Utc > {
524+ let ( ridx, cidx) = self . next_loc ( ) ?;
525+ let row = & self . rowbuf [ ridx] ;
526+ let val = row. try_get ( cidx) ?;
527+ match val {
528+ postgres:: types:: Timestamp :: PosInfinity => DateTime :: < Utc > :: MAX_UTC ,
529+ postgres:: types:: Timestamp :: NegInfinity => DateTime :: < Utc > :: MIN_UTC ,
530+ postgres:: types:: Timestamp :: Value ( t) => t,
531+ }
532+ }
533+ }
534+
535+ impl < ' r , ' a > Produce < ' r , Option < DateTime < Utc > > > for PostgresBinarySourcePartitionParser < ' a > {
536+ type Error = PostgresSourceError ;
537+
538+ #[ throws( PostgresSourceError ) ]
539+ fn produce ( & ' r mut self ) -> Option < DateTime < Utc > > {
540+ let ( ridx, cidx) = self . next_loc ( ) ?;
541+ let row = & self . rowbuf [ ridx] ;
542+ let val = row. try_get ( cidx) ?;
543+ match val {
544+ postgres:: types:: Timestamp :: PosInfinity => Some ( DateTime :: < Utc > :: MAX_UTC ) ,
545+ postgres:: types:: Timestamp :: NegInfinity => Some ( DateTime :: < Utc > :: MIN_UTC ) ,
546+ postgres:: types:: Timestamp :: Value ( t) => t,
547+ }
548+ }
549+ }
550+
551+ impl < ' r , ' a > Produce < ' r , NaiveDate > for PostgresBinarySourcePartitionParser < ' a > {
552+ type Error = PostgresSourceError ;
553+
554+ #[ throws( PostgresSourceError ) ]
555+ fn produce ( & ' r mut self ) -> NaiveDate {
556+ let ( ridx, cidx) = self . next_loc ( ) ?;
557+ let row = & self . rowbuf [ ridx] ;
558+ let val = row. try_get ( cidx) ?;
559+ match val {
560+ postgres:: types:: Date :: PosInfinity => NaiveDate :: MAX ,
561+ postgres:: types:: Date :: NegInfinity => NaiveDate :: MIN ,
562+ postgres:: types:: Date :: Value ( t) => t,
563+ }
564+ }
565+ }
566+
567+ impl < ' r , ' a > Produce < ' r , Option < NaiveDate > > for PostgresBinarySourcePartitionParser < ' a > {
568+ type Error = PostgresSourceError ;
569+
570+ #[ throws( PostgresSourceError ) ]
571+ fn produce ( & ' r mut self ) -> Option < NaiveDate > {
572+ let ( ridx, cidx) = self . next_loc ( ) ?;
573+ let row = & self . rowbuf [ ridx] ;
574+ let val = row. try_get ( cidx) ?;
575+ match val {
576+ postgres:: types:: Date :: PosInfinity => Some ( NaiveDate :: MAX ) ,
577+ postgres:: types:: Date :: NegInfinity => Some ( NaiveDate :: MIN ) ,
578+ postgres:: types:: Date :: Value ( t) => t,
579+ }
580+ }
581+ }
582+
487583impl < ' r , ' a > Produce < ' r , HashMap < String , Option < String > > >
488584 for PostgresBinarySourcePartitionParser < ' a >
489585{
@@ -1112,15 +1208,78 @@ impl_produce!(
11121208 & ' r str ,
11131209 Vec <u8 >,
11141210 NaiveTime ,
1115- NaiveDateTime ,
1116- DateTime <Utc >,
1117- // NaiveDate,
11181211 Uuid ,
11191212 Value ,
11201213 HashMap <String , Option <String >>,
11211214 Vec <String >,
11221215) ;
11231216
1217+ impl < ' r , ' a > Produce < ' r , DateTime < Utc > > for PostgresRawSourceParser < ' a > {
1218+ type Error = PostgresSourceError ;
1219+
1220+ #[ throws( PostgresSourceError ) ]
1221+ fn produce ( & ' r mut self ) -> DateTime < Utc > {
1222+ let ( ridx, cidx) = self . next_loc ( ) ?;
1223+ let row = & self . rowbuf [ ridx] ;
1224+ let val: postgres:: types:: Timestamp < DateTime < Utc > > = row. try_get ( cidx) ?;
1225+ match val {
1226+ postgres:: types:: Timestamp :: PosInfinity => DateTime :: < Utc > :: MAX_UTC ,
1227+ postgres:: types:: Timestamp :: NegInfinity => DateTime :: < Utc > :: MIN_UTC ,
1228+ postgres:: types:: Timestamp :: Value ( t) => t,
1229+ }
1230+ }
1231+ }
1232+
1233+ impl < ' r , ' a > Produce < ' r , Option < DateTime < Utc > > > for PostgresRawSourceParser < ' a > {
1234+ type Error = PostgresSourceError ;
1235+
1236+ #[ throws( PostgresSourceError ) ]
1237+ fn produce ( & ' r mut self ) -> Option < DateTime < Utc > > {
1238+ let ( ridx, cidx) = self . next_loc ( ) ?;
1239+ let row = & self . rowbuf [ ridx] ;
1240+ let val = row. try_get ( cidx) ?;
1241+ match val {
1242+ postgres:: types:: Timestamp :: PosInfinity => Some ( DateTime :: < Utc > :: MAX_UTC ) ,
1243+ postgres:: types:: Timestamp :: NegInfinity => Some ( DateTime :: < Utc > :: MIN_UTC ) ,
1244+ postgres:: types:: Timestamp :: Value ( t) => t,
1245+ }
1246+
1247+ }
1248+ }
1249+
1250+ impl < ' r , ' a > Produce < ' r , NaiveDateTime > for PostgresRawSourceParser < ' a > {
1251+ type Error = PostgresSourceError ;
1252+
1253+ #[ throws( PostgresSourceError ) ]
1254+ fn produce ( & ' r mut self ) -> NaiveDateTime {
1255+ let ( ridx, cidx) = self . next_loc ( ) ?;
1256+ let row = & self . rowbuf [ ridx] ;
1257+ let val: postgres:: types:: Timestamp < NaiveDateTime > = row. try_get ( cidx) ?;
1258+ match val {
1259+ postgres:: types:: Timestamp :: PosInfinity => NaiveDateTime :: MAX ,
1260+ postgres:: types:: Timestamp :: NegInfinity => NaiveDateTime :: MIN ,
1261+ postgres:: types:: Timestamp :: Value ( t) => t,
1262+ }
1263+ }
1264+ }
1265+
1266+ impl < ' r , ' a > Produce < ' r , Option < NaiveDateTime > > for PostgresRawSourceParser < ' a > {
1267+ type Error = PostgresSourceError ;
1268+
1269+ #[ throws( PostgresSourceError ) ]
1270+ fn produce ( & ' r mut self ) -> Option < NaiveDateTime > {
1271+ let ( ridx, cidx) = self . next_loc ( ) ?;
1272+ let row = & self . rowbuf [ ridx] ;
1273+ let val = row. try_get ( cidx) ?;
1274+ match val {
1275+ postgres:: types:: Timestamp :: PosInfinity => Some ( NaiveDateTime :: MAX ) ,
1276+ postgres:: types:: Timestamp :: NegInfinity => Some ( NaiveDateTime :: MIN ) ,
1277+ postgres:: types:: Timestamp :: Value ( t) => t,
1278+ }
1279+
1280+ }
1281+ }
1282+
11241283impl < ' r , ' a > Produce < ' r , NaiveDate > for PostgresRawSourceParser < ' a > {
11251284 type Error = PostgresSourceError ;
11261285
@@ -1145,7 +1304,12 @@ impl<'r, 'a> Produce<'r, Option<NaiveDate>> for PostgresRawSourceParser<'a> {
11451304 let ( ridx, cidx) = self . next_loc ( ) ?;
11461305 let row = & self . rowbuf [ ridx] ;
11471306 let val = row. try_get ( cidx) ?;
1148- val
1307+ match val {
1308+ postgres:: types:: Date :: PosInfinity => Some ( NaiveDate :: MAX ) ,
1309+ postgres:: types:: Date :: NegInfinity => Some ( NaiveDate :: MIN ) ,
1310+ postgres:: types:: Date :: Value ( t) => t,
1311+ }
1312+
11491313 }
11501314}
11511315
0 commit comments