pub fn insert_record_batch(
conn: &Connection,
dest_table: &str,
stream_name: &str,
batch: RecordBatch,
options: InsertOptions,
) -> Result<()>Expand description
Insert a single RecordBatch into dest_table via register_arrow_array.
stream_name is a temporary registration label (not a MergeTree table name).
dest_table must be a bare ClickHouse table identifier (e.g. metrics);
dotted names (db.table) and reserved identifiers are not quoted automatically.
Uses the fastest one-shot Arrow path for a single in-memory batch.
§Examples
use std::sync::Arc;
use arrow::array::{Int64Array, RecordBatch};
use arrow::datatypes::{DataType, Field, Schema};
use chdb_rust::arrow_insert::insert_record_batch;
use chdb_rust::InsertOptions;
use chdb_rust::connection::Connection;
let conn = Connection::open_in_memory()?;
conn.query(
"CREATE TABLE metrics (id Int64) ENGINE=MergeTree ORDER BY id",
chdb_rust::format::OutputFormat::TabSeparated,
)?;
let batch = RecordBatch::try_new(
Arc::new(Schema::new(vec![Field::new("id", DataType::Int64, false)])),
vec![Arc::new(Int64Array::from(vec![1i64, 2, 3]))],
)
.map_err(|e| chdb_rust::error::Error::QueryError(e.to_string()))?;
insert_record_batch(&conn, "metrics", "flush_1", batch, InsertOptions::default_bulk())?;§Errors
Returns an error if registration, the insert query, or unregistration fails.