clickhouse_arrow/
lib.rs

1#![doc = include_str!("../README.md")]
2
3pub mod arrow;
4mod client;
5mod compression;
6mod constants;
7mod errors;
8mod flags;
9mod formats;
10mod io;
11pub mod native;
12#[cfg(feature = "pool")]
13mod pool;
14pub mod prelude;
15mod query;
16mod schema;
17mod settings;
18pub mod spawn;
19pub mod telemetry;
20#[cfg(feature = "test_utils")]
21pub mod test_utils;
22
23#[cfg(feature = "derive")]
24/// Derive macro for the [Row] trait.
25///
26/// This is similar in usage and implementation to the [`serde::Serialize`] and
27/// [`serde::Deserialize`] derive macros.
28///
29/// ## serde attributes
30/// The following [serde attributes](https://serde.rs/attributes.html) are supported, using `#[clickhouse_arrow(...)]` instead of `#[serde(...)]`:
31/// - `with`
32/// - `from` and `into`
33/// - `try_from`
34/// - `skip`
35/// - `default`
36/// - `deny_unknown_fields`
37/// - `rename`
38/// - `rename_all`
39/// - `serialize_with`, `deserialize_with`
40/// - `skip_deserializing`, `skip_serializing`
41/// - `flatten`
42///    - Index-based matching is disabled (the column names must match exactly).
43///    - Due to the current interface of the [Row] trait, performance might not be optimal, as
44///      a value map must be reconstitued for each flattened subfield.
45///
46/// ## ClickHouse-specific attributes
47/// - The `nested` attribute allows handling [ClickHouse nested data structures](https://clickhouse.com/docs/en/sql-reference/data-types/nested-data-structures/nested).
48///   See an example in the `tests` folder.
49///
50/// ## Known issues
51/// - For serialization, the ordering of fields in the struct declaration must match the order in the `INSERT` statement, respectively in the table declaration. See issue [#34](https://github.com/Protryon/clickhouse_arrow/issues/34).
52pub use clickhouse_arrow_derive::Row;
53pub use client::*;
54/// Set this environment to enable additional debugs around arrow (de)serialization.
55pub use constants::{CONN_READ_BUFFER_ENV_VAR, CONN_WRITE_BUFFER_ENV_VAR, DEBUG_ARROW_ENV_VAR};
56pub use errors::*;
57pub use formats::{ArrowFormat, ClientFormat, NativeFormat};
58/// Contains useful top-level traits to interface with [`crate::prelude::NativeFormat`]
59pub use native::convert::*;
60pub use native::progress::Progress;
61pub use native::protocol::{ChunkedProtocolMode, ProfileEvent};
62/// Represents the types that `ClickHouse` supports internally.
63pub use native::types::*;
64/// Contains useful top-level structures to interface with [`crate::prelude::NativeFormat`]
65pub use native::values::*;
66pub use native::{CompressionMethod, ServerError, Severity};
67#[cfg(feature = "pool")]
68pub use pool::*;
69pub use query::{ParamValue, ParsedQuery, Qid, QueryParams};
70pub use schema::CreateOptions;
71pub use settings::{Setting, SettingValue, Settings};
72
73mod aliases {
74    /// A non-cryptographically secure [`std::hash::BuildHasherDefault`] using
75    /// [`rustc_hash::FxHasher`].
76    pub type HashBuilder = std::hash::BuildHasherDefault<rustc_hash::FxHasher>;
77    /// A non-cryptographically secure [`indexmap::IndexMap`] using [`HashBuilder`].
78    pub type FxIndexMap<K, V> = indexmap::IndexMap<K, V, HashBuilder>;
79}
80// Type aliases used throughout the library
81pub use aliases::*;
82// External libraries
83mod reexports {
84    #[cfg(feature = "pool")]
85    pub use bb8;
86    pub use chrono_tz::Tz;
87    pub use indexmap::IndexMap;
88    pub use uuid::Uuid;
89    pub use {rustc_hash, tracing};
90}
91/// Re-exports
92///
93/// Exporting different external modules used by the library.
94pub use reexports::*;
95
96#[cfg(test)]
97mod dev_deps {
98    //! This is here to silence rustc's unused-crate-dependencies warnings.
99    //! See tracking issue [#95513](https://github.com/rust-lang/rust/issues/95513).
100    use {clickhouse as _, criterion as _};
101}