laminar_connectors/lakehouse/delta_io/
mod.rs1mod attempt_error;
19mod catalog;
20mod descriptor;
21#[cfg(feature = "delta-lake-gcs")]
22mod gcs_factory;
23mod merge;
24mod publication;
25mod read;
26mod storage_preflight;
27mod table;
28
29#[cfg(feature = "delta-lake")]
30pub use catalog::resolve_catalog_options;
31#[cfg(feature = "delta-lake")]
32pub use merge::MergeResult;
33#[cfg(feature = "delta-lake")]
34pub use read::{
35 get_latest_version, get_partition_columns, get_table_schema, map_cdf_to_changelog,
36 read_cdf_batches,
37};
38#[cfg(feature = "delta-lake")]
39pub use table::{get_coordinated_cursor, open_or_create_table};
40
41#[cfg(feature = "delta-lake")]
42pub(crate) use attempt_error::{
43 classify_delta_metadata_error, classify_delta_object_store_metadata_error,
44 delta_error_category, delta_error_has_retryable_transport,
45 is_definite_coordinated_nonpublication, DeltaWriteAttemptError,
46};
47#[cfg(feature = "delta-lake")]
48pub(crate) use merge::merge_changelog;
49#[cfg(feature = "delta-lake")]
50pub(crate) use read::read_batches_at_version;
51#[cfg(feature = "delta-lake")]
52pub(crate) use table::{
53 widen_batch_millisecond_timestamps, widen_millisecond_timestamps, write_batches,
54};
55
56#[cfg(all(feature = "delta-lake", test))]
57pub(super) use descriptor::decode_commit_descriptors;
58#[cfg(feature = "delta-lake")]
59pub(super) use descriptor::{
60 coordinated_table_binding, encode_commit_descriptor, encoded_add_array_len,
61 MAX_COORDINATED_ADD_ACTIONS,
62};
63#[cfg(feature = "delta-lake")]
64pub(super) use publication::commit_batch_coordinated;
65#[cfg(all(feature = "delta-lake", test))]
66pub(super) use publication::{
67 commit_adds_coordinated, DelayedCoordinatedCatalogCommit, DELAY_COORDINATED_CATALOG_COMMIT,
68};
69#[cfg(feature = "delta-lake")]
70pub(super) use storage_preflight::{
71 bound_coordinated_storage_options, validate_coordinated_storage_preflight,
72};
73
74#[cfg(feature = "delta-lake")]
75use descriptor::{
76 decode_commit_descriptors_until, ensure_publication_deadline, validate_coordinated_descriptors,
77 CoordinatedObject,
78};
79#[cfg(feature = "delta-lake")]
80use storage_preflight::validate_coordinated_log_store;
81#[cfg(feature = "delta-lake")]
82use table::coordinated_transaction_ids;
83
84#[cfg(all(feature = "delta-lake", test))]
85use descriptor::{
86 validate_descriptor_batch_lengths, MAX_COORDINATED_PARTITION_BYTES, MAX_COORDINATED_PATH_BYTES,
87 MAX_COORDINATED_STATS_BYTES,
88};
89#[cfg(all(feature = "delta-lake", test))]
90use publication::validate_coordinated_retention;
91#[cfg(all(feature = "delta-lake", test))]
92use read::{checked_cdf_commit_usage, map_cdf_scan_build_error};
93#[cfg(all(feature = "delta-lake", test))]
94use storage_preflight::{
95 is_certified_coordinated_log_store, validate_coordinated_storage_preflight_with_env,
96};
97#[cfg(all(feature = "delta-lake", test))]
98use table::{adapt_delta_location, apply_url_derived_options, path_to_url};
99
100#[cfg(feature = "delta-lake")]
101use std::collections::{BTreeMap, HashMap, HashSet};
102
103#[cfg(feature = "delta-lake")]
104use std::sync::Arc;
105
106#[cfg(feature = "delta-lake")]
107use std::sync::atomic::{AtomicUsize, Ordering};
108
109#[cfg(feature = "delta-lake")]
110use std::time::Duration;
111
112#[cfg(feature = "delta-lake")]
113use arrow_array::RecordBatch;
114
115#[cfg(feature = "delta-lake")]
116use arrow_schema::SchemaRef;
117
118#[cfg(feature = "delta-lake")]
119use deltalake::kernel::transaction::CommitProperties;
120
121#[cfg(feature = "delta-lake")]
122use deltalake::kernel::Transaction;
123
124#[cfg(feature = "delta-lake")]
125use deltalake::operations::write::SchemaMode;
126
127#[cfg(feature = "delta-lake")]
128use deltalake::protocol::SaveMode;
129
130#[cfg(feature = "delta-lake")]
131use deltalake::DeltaTable;
132
133#[cfg(feature = "delta-lake")]
134use tracing::{debug, info};
135
136#[cfg(feature = "delta-lake")]
137use url::Url;
138
139#[cfg(feature = "delta-lake")]
140use crate::error::ConnectorError;
141
142#[cfg(feature = "delta-lake")]
143use crate::storage::StorageProvider;
144
145#[cfg(feature = "delta-lake")]
146use crate::connector::{
147 CoordinatedCommitBatch, CoordinatedCommitCursor, MAX_COORDINATED_COMMIT_BATCH_BYTES,
148};
149
150#[cfg(feature = "delta-lake")]
151use super::commit_descriptor::{DeltaCommitDescriptor, DeltaTableBinding};
152
153#[cfg(feature = "delta-lake")]
154pub(super) fn to_delta_version(version: i64) -> Result<u64, ConnectorError> {
155 u64::try_from(version).map_err(|_| {
156 ConnectorError::ConfigurationError(format!(
157 "Delta table version must be non-negative, got {version}"
158 ))
159 })
160}
161
162#[cfg(feature = "delta-lake")]
163pub(super) fn from_delta_version(version: u64) -> Result<i64, ConnectorError> {
164 i64::try_from(version).map_err(|_| {
165 ConnectorError::ReadError(format!(
166 "Delta table version {version} exceeds LaminarDB's supported range"
167 ))
168 })
169}
170
171#[cfg(feature = "delta-lake")]
172const SET_TRANSACTION_RETENTION: &str = "delta.setTransactionRetentionDuration";
173
174#[cfg(feature = "delta-lake")]
175const COORDINATED_HEAD_CONCURRENCY: usize = 16;
176
177#[cfg(feature = "delta-lake")]
182const COORDINATED_REQUEST_TIMEOUT: &str = "30s";
183#[cfg(feature = "delta-lake")]
184const COORDINATED_CONNECT_TIMEOUT: &str = "10s";
185#[cfg(feature = "delta-lake")]
186const COORDINATED_RETRY_TIMEOUT: &str = "30s";
187#[cfg(feature = "delta-lake")]
188const COORDINATED_HTTP_MAX_RETRIES: &str = "0";
189#[cfg(feature = "delta-lake")]
190const COORDINATED_MAX_BACKOFF: &str = "1s";
191#[cfg(feature = "delta-lake")]
192const COORDINATED_TERMINAL_IO_HORIZON: Duration = Duration::from_secs(24 * 60 * 60);
193#[cfg(feature = "delta-lake")]
194const COORDINATED_CLOCK_SKEW_MARGIN: Duration = Duration::from_secs(5 * 60);
195#[cfg(feature = "delta-lake")]
196const MIN_COORDINATED_DELETED_FILE_RETENTION: Duration = Duration::from_secs(7 * 24 * 60 * 60);
197
198#[cfg(all(test, feature = "delta-lake"))]
199mod tests;