Build insert batches from not-matched rows, applying INSERT clause projections and predicates.
(
ctx: &SQLContext,
not_matched_batches: &[RecordBatch],
inserts: &[MergeInsertClause],
s_alias: &str,
injected_columns: &[String],
table_fields: &[String],
temp_tracker: &
| 827 | |
| 828 | /// Build insert batches from not-matched rows, applying INSERT clause projections and predicates. |
| 829 | async fn build_insert_batches( |
| 830 | ctx: &SQLContext, |
| 831 | not_matched_batches: &[RecordBatch], |
| 832 | inserts: &[MergeInsertClause], |
| 833 | s_alias: &str, |
| 834 | injected_columns: &[String], |
| 835 | table_fields: &[String], |
| 836 | temp_tracker: &mut TempTableTracker<'_>, |
| 837 | ) -> DFResult<Vec<RecordBatch>> { |
| 838 | if not_matched_batches.is_empty() || not_matched_batches.iter().all(|b| b.num_rows() == 0) { |
| 839 | return Ok(Vec::new()); |
| 840 | } |
| 841 | |
| 842 | // Strip injected columns (_ROW_ID, __upd_*) — keep only source columns |
| 843 | let source_batches = strip_non_source_columns(not_matched_batches, injected_columns)?; |
| 844 | |
| 845 | // Register as temp table for SQL-based projection/filtering |
| 846 | let first_schema = source_batches[0].schema(); |
| 847 | let tmp_name = next_cow_table_name("__merge_not_matched"); |
| 848 | |
| 849 | let mem_table = datafusion::datasource::MemTable::try_new(first_schema, vec![source_batches])?; |
| 850 | ctx.register_temp_table(&tmp_name, Arc::new(mem_table))?; |
| 851 | temp_tracker.register(&tmp_name); |
| 852 | |
| 853 | let result = build_insert_batches_inner(ctx, inserts, s_alias, &tmp_name, table_fields).await; |
| 854 | |
| 855 | result |
| 856 | } |
| 857 | |
| 858 | /// Execute INSERT clause queries against the registered temp table. |
| 859 | async fn build_insert_batches_inner( |
no test coverage detected