Execute a DELETE statement on a Paimon table. `table_ref` is the SQL table reference string (e.g. `"paimon.test_db.t"`), already extracted by the caller for catalog resolution.
(
ctx: &SQLContext,
delete: &Delete,
table: Table,
table_ref: &str,
)
| 39 | /// `table_ref` is the SQL table reference string (e.g. `"paimon.test_db.t"`), |
| 40 | /// already extracted by the caller for catalog resolution. |
| 41 | pub(crate) async fn execute_delete( |
| 42 | ctx: &SQLContext, |
| 43 | delete: &Delete, |
| 44 | table: Table, |
| 45 | table_ref: &str, |
| 46 | ) -> DFResult<DataFrame> { |
| 47 | let tables = match &delete.from { |
| 48 | FromTable::WithFromKeyword(t) | FromTable::WithoutKeyword(t) => t, |
| 49 | }; |
| 50 | if let Some(first) = tables.first() { |
| 51 | if let TableFactor::Table { alias: Some(a), .. } = &first.relation { |
| 52 | return Err(DataFusionError::Plan(format!( |
| 53 | "Table alias '{}' in DELETE is not yet supported", |
| 54 | a.name.value |
| 55 | ))); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | let schema = table.schema(); |
| 60 | let core_options = CoreOptions::new(schema.options()); |
| 61 | |
| 62 | if core_options.data_evolution_enabled() { |
| 63 | return Err(DataFusionError::Plan( |
| 64 | "DELETE on data-evolution tables is not yet supported".to_string(), |
| 65 | )); |
| 66 | } |
| 67 | if !schema.trimmed_primary_keys().is_empty() { |
| 68 | return Err(DataFusionError::Plan( |
| 69 | "DELETE on primary-key tables is not yet supported".to_string(), |
| 70 | )); |
| 71 | } |
| 72 | |
| 73 | execute_cow_delete(ctx, delete, &table, table_ref).await |
| 74 | } |
| 75 | |
| 76 | /// Execute DELETE on an append-only table with retry on delete conflict. |
| 77 | async fn execute_cow_delete( |
no test coverage detected