MCPcopy Create free account
hub / github.com/apache/paimon-rust / build_insert_batches

Function build_insert_batches

crates/integrations/datafusion/src/merge_into.rs:829–856  ·  view source on GitHub ↗

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: &

Source from the content-addressed store, hash-verified

827
828/// Build insert batches from not-matched rows, applying INSERT clause projections and predicates.
829async 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.
859async fn build_insert_batches_inner(

Callers 2

execute_cow_merge_innerFunction · 0.85
execute_merge_into_onceFunction · 0.85

Calls 9

strip_non_source_columnsFunction · 0.85
next_cow_table_nameFunction · 0.85
num_rowsMethod · 0.80
registerMethod · 0.80
is_emptyMethod · 0.45
iterMethod · 0.45
schemaMethod · 0.45
register_temp_tableMethod · 0.45

Tested by

no test coverage detected