From 783e99feb7c41d3688a17ff898dd12a87704b424 Mon Sep 17 00:00:00 2001 From: albertlockett Date: Thu, 18 Jul 2024 16:00:53 -0300 Subject: [PATCH] support passing write parameters to merge_insert --- rust/lancedb/src/table.rs | 6 ++++++ rust/lancedb/src/table/merge.rs | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/rust/lancedb/src/table.rs b/rust/lancedb/src/table.rs index 29ee3528..dcdbe5d0 100644 --- a/rust/lancedb/src/table.rs +++ b/rust/lancedb/src/table.rs @@ -1854,6 +1854,12 @@ impl TableInternal for NativeTable { } else { builder.when_not_matched_by_source(WhenNotMatchedBySource::Keep); } + + if let Some(write_options) = params.write_options { + if let Some(write_params) = &write_options.lance_write_params { + builder.with_write_params(write_params.clone()); + } + } let job = builder.try_build()?; let (new_dataset, _stats) = job.execute_reader(new_data).await?; self.dataset.set_latest(new_dataset.as_ref().clone()).await; diff --git a/rust/lancedb/src/table/merge.rs b/rust/lancedb/src/table/merge.rs index 5c422b9d..43f71126 100644 --- a/rust/lancedb/src/table/merge.rs +++ b/rust/lancedb/src/table/merge.rs @@ -18,7 +18,7 @@ use arrow_array::RecordBatchReader; use crate::Result; -use super::TableInternal; +use super::{TableInternal, WriteOptions}; /// A builder used to create and run a merge insert operation /// @@ -32,6 +32,8 @@ pub struct MergeInsertBuilder { pub(super) when_not_matched_insert_all: bool, pub(super) when_not_matched_by_source_delete: bool, pub(super) when_not_matched_by_source_delete_filt: Option, + pub(crate) write_options: Option + } impl MergeInsertBuilder { @@ -44,6 +46,7 @@ impl MergeInsertBuilder { when_not_matched_insert_all: false, when_not_matched_by_source_delete: false, when_not_matched_by_source_delete_filt: None, + write_options: None, } } @@ -95,6 +98,12 @@ impl MergeInsertBuilder { self } + /// Apply the given write options when updating the dataset + pub fn write_options(&mut self, write_options: Option) -> &mut Self { + self.write_options = write_options; + self + } + /// Executes the merge insert operation /// /// Nothing is returned but the [`super::Table`] is updated