u70b3 opened a new issue, #2713: URL: https://github.com/apache/iceberg-rust/issues/2713
### Apache Iceberg Rust version\n\nCurrent `main` at `ac92ec9` (version 0.10.0).\n\n### Describe the bug\n\nWhen an `INSERT INTO ... SELECT ... WHERE false` (or any other insert that produces zero rows) is executed through the DataFusion integration, `IcebergCommitExec` returns an empty `RecordBatch` and still creates a new table snapshot.\n\nDataFusion expects an `INSERT` statement to always produce a single-row, single-column result containing the affected row count (0 in this case). Returning an empty batch violates this contract and can confuse downstream consumers.\n\nAdditionally, creating a snapshot for an insert that wrote no data files is unnecessary and pollutes table history.\n\n### To Reproduce\n\n1. Create an Iceberg table through the DataFusion catalog.\n2. Execute `INSERT INTO catalog.my_table SELECT * FROM (VALUES (1, 'a')) AS t(foo1, foo2) WHERE false`.\n3. Collect the result batches.\n4. Observe that the returned batch has zero rows instead of one row with count `0`.\n5. Load the table metadata and observe that a snapshot is created even though no data files were written.\n\nRelevant code:\n\n* `crates/integrations/datafusion/src/physical_plan/commit.rs` returns `RecordBatch::new_empty(...)` when `data_files` is empty.\n* The commit path does not short-circuit before starting a transaction for empty inserts.\n\n### Expected behavior\n\n* `IcebergCommitExec` should return a single-row `RecordBatch` with a `UInt64` count column set to `0` when no data files are produced.\n* No new snapshot should be created for an empty insert.\n\n### Willingness to contribute\n\nI can contribute a fix for this bug independently. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
