ProductDocsArchitectureBlogGitHubGitHubGet Started
Available

Rust API Overview

Public API surface of the krishiv-api crate.

Overview

The krishiv-api crate is the user-facing Rust API. It re-exports every public type at the crate root. Add it to your Cargo.toml:

[dependencies]
krishiv = { path = "../krishiv", features = ["embedded"] }

Or use the api crate directly:

[dependencies]
krishiv-api = { path = "../crates/krishiv-api" }

Key Top-Level Exports

Type / FunctionDescription
Session, SessionBuilderEntry point for all Krishiv workloads.
DataFrame, GroupedDataFrameLazy query plan builder.
Stream, KeyedStreamStreaming data pipeline builder.
IncrementalFlowIncremental view maintenance.
WindowedStream, SessionWindowedStream, SlidingWindowedStreamWindowed streaming aggregation.
DataStreamReader, DataStreamWriter, StreamingQueryStructured streaming API (Spark-style).
QueryHandle, QueryResultAsync query execution and result collection.
PreparedStatementParameterised SQL statements.
col, lit, expr, avg, count, sum, min, maxExpression builder functions.
Pipeline, PipelineBuilderSource-to-sink pipeline execution.
ValueState, MapState, ListStateKeyed operator state.
KrishivError, ResultError type and alias.
RecordBatch, Schema, Field, DataTypeRe-exported Arrow types.

Quick Example

use krishiv_api::{Session, Result, col, lit};

#[tokio::main]
async fn main() -> Result<()> {
    let session = Session::embedded().await?;

    // SQL path
    let result = session.sql("SELECT 1 + 1 AS two").await?.collect().await?;

    // DataFrame path
    let df = session.read_parquet("data/sales.parquet").await?
        .filter(col("amount").gt(lit(100)))?
        .select(&["customer_id", "amount"])?;
    df.show().await?;

    Ok(())
}