Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions crates/integrations/datafusion/src/table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ impl TableProvider for IcebergTableProvider {
input: Arc<dyn ExecutionPlan>,
_insert_op: InsertOp,
) -> DFResult<Arc<dyn ExecutionPlan>> {
if _insert_op != InsertOp::Append {
return Err(DataFusionError::NotImplemented(format!(
"IcebergTableProvider supports only append inserts, got {_insert_op}"
)));
}

// Load fresh table metadata from catalog
let table = self
.catalog
Expand Down Expand Up @@ -710,6 +716,42 @@ mod tests {
false
}

#[tokio::test]
async fn test_catalog_backed_provider_rejects_non_append_op() {
use datafusion::physical_plan::empty::EmptyExec;

let (catalog, namespace, table_name, _temp_dir) = get_test_catalog_and_table().await;
let provider = IcebergTableProvider::try_new(catalog, namespace, table_name)
.await
.unwrap();
let ctx = SessionContext::new();

for (insert_op, expected_message) in [
(
InsertOp::Overwrite,
"IcebergTableProvider supports only append inserts, got Insert Overwrite",
),
(
InsertOp::Replace,
"IcebergTableProvider supports only append inserts, got Replace Into",
),
] {
let input = Arc::new(EmptyExec::new(provider.schema())) as Arc<dyn ExecutionPlan>;
let error = provider
.insert_into(&ctx.state(), input, insert_op)
.await
.expect_err("non-append inserts should be rejected");

assert!(
matches!(
error,
DataFusionError::NotImplemented(ref message) if message == expected_message
),
"unexpected error: {error}"
);
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about merging these 2 tests into 1 test_catalog_backed_provider_rejects_non_append_op

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the comment, already merge two testcase


#[tokio::test]
async fn test_insert_plan_fanout_enabled_no_sort() {
use datafusion::datasource::TableProvider;
Expand Down
Loading