connectorx/transports/
bigquery_arrowstream.rs1use crate::{
4 destinations::arrowstream::{
5 typesystem::ArrowTypeSystem, ArrowDestination, ArrowDestinationError,
6 },
7 impl_transport,
8 sources::bigquery::{BigQuerySource, BigQuerySourceError, BigQueryTypeSystem},
9 typesystem::TypeConversion,
10};
11use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc};
12use thiserror::Error;
13
14#[derive(Error, Debug)]
15pub enum BigQueryArrowTransportError {
16 #[error(transparent)]
17 Source(#[from] BigQuerySourceError),
18
19 #[error(transparent)]
20 Destination(#[from] ArrowDestinationError),
21
22 #[error(transparent)]
23 ConnectorX(#[from] crate::errors::ConnectorXError),
24}
25
26pub struct BigQueryArrowTransport;
28
29impl_transport!(
30 name = BigQueryArrowTransport,
31 error = BigQueryArrowTransportError,
32 systems = BigQueryTypeSystem => ArrowTypeSystem,
33 route = BigQuerySource => ArrowDestination,
34 mappings = {
35 { Bool[bool] => Boolean[bool] | conversion auto }
36 { Boolean[bool] => Boolean[bool] | conversion none }
37 { Int64[i64] => Int64[i64] | conversion auto }
38 { Integer[i64] => Int64[i64] | conversion none }
39 { Float64[f64] => Float64[f64] | conversion auto }
40 { Float[f64] => Float64[f64] | conversion none }
41 { Numeric[f64] => Float64[f64] | conversion none }
42 { Bignumeric[f64] => Float64[f64] | conversion none }
43 { String[String] => LargeUtf8[String] | conversion auto }
44 { Bytes[String] => LargeUtf8[String] | conversion none }
45 { Date[NaiveDate] => Date32[NaiveDate] | conversion auto }
46 { Datetime[NaiveDateTime] => Date64[NaiveDateTime] | conversion auto }
47 { Time[NaiveTime] => Time64[NaiveTime] | conversion auto }
48 { Timestamp[DateTime<Utc>] => DateTimeTz[DateTime<Utc>] | conversion auto }
49 }
50);