support passing write parameters to merge_insert

This commit is contained in:
albertlockett
2024-07-18 16:00:53 -03:00
parent 1415d1a23a
commit 783e99feb7
2 changed files with 16 additions and 1 deletions

View File

@@ -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;

View File

@@ -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<String>,
pub(crate) write_options: Option<WriteOptions>
}
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<WriteOptions>) -> &mut Self {
self.write_options = write_options;
self
}
/// Executes the merge insert operation
///
/// Nothing is returned but the [`super::Table`] is updated