Skip to main content

connectorx/
constants.rs

1#[cfg(feature = "dst_arrow")]
2use arrow::datatypes::DataType as ArrowDataType;
3
4/// Precision used for Arrow `Decimal128` columns when the source does not give one.
5#[cfg(feature = "dst_arrow")]
6pub const DEFAULT_ARROW_DECIMAL_PRECISION: u8 = 38;
7
8/// Scale used for Arrow `Decimal128` columns when the source does not give one.
9#[cfg(feature = "dst_arrow")]
10pub const DEFAULT_ARROW_DECIMAL_SCALE: i8 = 10;
11
12/// Default Arrow decimal type, `Decimal128(38, 10)`.
13#[cfg(feature = "dst_arrow")]
14pub const DEFAULT_ARROW_DECIMAL: ArrowDataType =
15    ArrowDataType::Decimal128(DEFAULT_ARROW_DECIMAL_PRECISION, DEFAULT_ARROW_DECIMAL_SCALE);
16
17#[cfg(feature = "dst_arrow")]
18pub(crate) const SECONDS_IN_DAY: i64 = 86_400;
19
20#[allow(dead_code)]
21const KILO: usize = 1 << 10;
22
23/// Default number of rows per Arrow record batch.
24#[cfg(feature = "dst_arrow")]
25pub const RECORD_BATCH_SIZE: usize = 64 * KILO;
26
27/// Number of rows buffered per fetch by the row-based database sources.
28#[cfg(any(
29    feature = "src_postgres",
30    feature = "src_mysql",
31    feature = "src_oracle",
32    feature = "src_mssql_common"
33))]
34pub const DB_BUFFER_SIZE: usize = 32;
35
36/// Number of rows Oracle prefetches per round trip.
37#[cfg(feature = "src_oracle")]
38pub const ORACLE_ARRAY_SIZE: u32 = KILO as u32;
39
40/// Directory holding the j4rs jars used by the federated query rewriter.
41#[cfg(all(not(debug_assertions), feature = "federation"))]
42pub const J4RS_BASE_PATH: &str = "../target/release";
43
44/// Directory holding the j4rs jars used by the federated query rewriter.
45#[cfg(all(debug_assertions, feature = "federation"))]
46pub const J4RS_BASE_PATH: &str = "../target/debug";
47
48/// Default path of the federated query rewriter jar.
49#[cfg(feature = "federation")]
50pub const CX_REWRITER_PATH: &str =
51    "../connectorx-python/connectorx/dependencies/federated-rewriter.jar";
52
53/// JDBC driver class for Postgres, used by the federated rewriter.
54#[cfg(feature = "federation")]
55pub const POSTGRES_JDBC_DRIVER: &str = "org.postgresql.Driver";
56
57/// JDBC driver class for MySQL, used by the federated rewriter.
58#[cfg(feature = "federation")]
59pub const MYSQL_JDBC_DRIVER: &str = "com.mysql.cj.jdbc.Driver";
60
61/// JDBC driver class for DuckDB, used by the federated rewriter.
62#[cfg(feature = "federation")]
63pub const DUCKDB_JDBC_DRIVER: &str = "org.duckdb.DuckDBDriver";
64
65/// Connection string query parameter that selects the ConnectorX protocol (e.g. `binary`, `csv`).
66pub const CONNECTORX_PROTOCOL: &str = "cxprotocol";