|
4 | 4 | use deltalake::arrow::datatypes::Schema as ArrowSchema; |
5 | 5 | use deltalake::kernel::engine::arrow_conversion::TryFromArrow; |
6 | 6 | use deltalake::kernel::schema::{Schema, StructField}; |
| 7 | +use deltalake::kernel::transaction::{CommitBuilder, CommitProperties}; |
7 | 8 | use deltalake::logstore::{LogStoreRef, ObjectStoreRef, StorageConfig, logstore_for}; |
8 | 9 | use deltalake::operations::create::CreateBuilder; |
9 | 10 | use deltalake::parquet::arrow::async_reader::{ |
@@ -207,18 +208,21 @@ pub async fn create_table_with( |
207 | 208 | .await |
208 | 209 | } |
209 | 210 |
|
| 211 | +/// Return the common default [CommitProperties] to be used by issuing commits in oxbow |
| 212 | +pub(crate) fn default_commit_properties() -> CommitProperties { |
| 213 | + CommitProperties::default() |
| 214 | + // Turn off cleanup of expired logs. After each commit, versions are |
| 215 | + // scanned (ListObject on s3) to clean up expired entries. This creates |
| 216 | + // significant overhead when there are many versions on each commit. |
| 217 | + .with_cleanup_expired_logs(Some(false)) |
| 218 | +} |
| 219 | + |
210 | 220 | /// Commit the given [Action]s to the [DeltaTable] |
211 | 221 | pub async fn commit_to_table(actions: &[Action], table: &DeltaTable) -> DeltaResult<i64> { |
212 | | - use deltalake::kernel::transaction::{CommitBuilder, CommitProperties}; |
213 | 222 | if actions.is_empty() { |
214 | 223 | return table.version().ok_or(DeltaTableError::NotInitialized); |
215 | 224 | } |
216 | | - let commit = CommitProperties::default() |
217 | | - // Turn off cleanup of expired logs. After each commit, versions are |
218 | | - // scanned (ListObject on s3) to clean up expired entries. This creates |
219 | | - // significant overhead when there are many versions on each commit. |
220 | | - .with_cleanup_expired_logs(Some(false)); |
221 | | - let pre_commit = CommitBuilder::from(commit) |
| 225 | + let pre_commit = CommitBuilder::from(default_commit_properties()) |
222 | 226 | .with_actions(actions.to_vec()) |
223 | 227 | .build( |
224 | 228 | Some(table.snapshot()?), |
@@ -1226,7 +1230,6 @@ mod tests { |
1226 | 1230 | let table_url = Url::from_file_path(&table_path).expect("Failed to parse local path"); |
1227 | 1231 | let store = |
1228 | 1232 | logstore_for(table_url, StorageConfig::default()).expect("Failed to get object store"); |
1229 | | - |
1230 | 1233 | let files = discover_parquet_files(store.object_store(None).clone()) |
1231 | 1234 | .await |
1232 | 1235 | .expect("Failed to discover parquet files"); |
|
0 commit comments