Execute an UPDATE statement on a Paimon table.
(
ctx: &SQLContext,
update: &Update,
table: Table,
)
| 43 | |
| 44 | /// Execute an UPDATE statement on a Paimon table. |
| 45 | pub(crate) async fn execute_update( |
| 46 | ctx: &SQLContext, |
| 47 | update: &Update, |
| 48 | table: Table, |
| 49 | ) -> DFResult<DataFrame> { |
| 50 | if let TableFactor::Table { alias: Some(a), .. } = &update.table.relation { |
| 51 | return Err(DataFusionError::Plan(format!( |
| 52 | "Table alias '{}' in UPDATE is not yet supported", |
| 53 | a.name.value |
| 54 | ))); |
| 55 | } |
| 56 | |
| 57 | let schema = table.schema(); |
| 58 | let core_options = CoreOptions::new(schema.options()); |
| 59 | |
| 60 | if core_options.data_evolution_enabled() { |
| 61 | execute_data_evolution_update(ctx, update, table).await |
| 62 | } else if schema.trimmed_primary_keys().is_empty() { |
| 63 | execute_cow_update(ctx, update, &table).await |
| 64 | } else { |
| 65 | Err(DataFusionError::Plan( |
| 66 | "UPDATE on primary-key tables without data-evolution is not supported".to_string(), |
| 67 | )) |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | // --------------------------------------------------------------------------- |
| 72 | // Data evolution path |