1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use crate::impl_typesystem;
use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc};

#[derive(Debug, Clone, Copy)]
pub struct DateTimeWrapperMicro(pub DateTime<Utc>);

#[derive(Debug, Clone, Copy)]
pub struct NaiveTimeWrapperMicro(pub NaiveTime);

#[derive(Debug, Clone, Copy)]
pub struct NaiveDateTimeWrapperMicro(pub NaiveDateTime);

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Arrow2TypeSystem {
    Int32(bool),
    Int64(bool),
    UInt32(bool),
    UInt64(bool),
    Float32(bool),
    Float64(bool),
    Boolean(bool),
    LargeUtf8(bool),
    LargeBinary(bool),
    Date32(bool),
    Date64(bool),
    Date64Micro(bool),
    Time64(bool),
    Time64Micro(bool),
    DateTimeTz(bool),
    DateTimeTzMicro(bool),
    BoolArray(bool),
    Int32Array(bool),
    Int64Array(bool),
    UInt32Array(bool),
    UInt64Array(bool),
    Float32Array(bool),
    Float64Array(bool),
    Utf8Array(bool),
}

impl_typesystem! {
    system = Arrow2TypeSystem,
    mappings = {
        { Int32           => i32           }
        { Int64           => i64           }
        { UInt32          => u32           }
        { UInt64          => u64           }
        { Float64         => f64           }
        { Float32         => f32           }
        { Boolean         => bool          }
        { LargeUtf8       => String        }
        { LargeBinary     => Vec<u8>       }
        { Date32          => NaiveDate     }
        { Date64          => NaiveDateTime }
        { Date64Micro     => NaiveDateTimeWrapperMicro }
        { Time64          => NaiveTime     }
        { Time64Micro     => NaiveTimeWrapperMicro }
        { DateTimeTz      => DateTime<Utc> }
        { DateTimeTzMicro => DateTimeWrapperMicro }
        { BoolArray       => Vec<bool>     }
        { Int32Array      => Vec<i32>      }
        { Int64Array      => Vec<i64>      }
        { UInt32Array     => Vec<u32>      }
        { UInt64Array     => Vec<u64>      }
        { Float32Array    => Vec<f32>      }
        { Float64Array    => Vec<f64>      }
        { Utf8Array       => Vec<String>   }
    }
}