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