(table: &Table, records: &[ArticleRecord])
| 228 | } |
| 229 | |
| 230 | pub async fn upsert_articles(table: &Table, records: &[ArticleRecord]) -> Result<()> { |
| 231 | if records.is_empty() { |
| 232 | return Ok(()); |
| 233 | } |
| 234 | let batch = align_batch_to_table_schema(table, build_article_batch(records)?).await?; |
| 235 | let schema = batch.schema(); |
| 236 | let batches = RecordBatchIterator::new(vec![Ok(batch)].into_iter(), schema); |
| 237 | |
| 238 | let mut merge = table.merge_insert(&["id"]); |
| 239 | merge.when_matched_update_all(None); |
| 240 | merge.when_not_matched_insert_all(); |
| 241 | merge.execute(Box::new(batches)).await?; |
| 242 | Ok(()) |
| 243 | } |
| 244 | |
| 245 | pub async fn upsert_images(table: &Table, records: &[ImageRecord]) -> Result<()> { |
| 246 | if records.is_empty() { |
no test coverage detected