A lightweight runtime for executing federated data plans.
⚠️ v1 is in preparation. Untilv1.0.0, minor API adjustments may still occur.
go get github.com/kvatch-hub/kvatch-runtimepackage main
import (
"context"
"fmt"
"log"
"github.com/kvatch-hub/kvatch-runtime/model"
"github.com/kvatch-hub/kvatch-runtime/pkg/runtime"
)
func main() {
rt, err := runtime.NewDefault()
if err != nil {
log.Fatal(err)
}
plan := model.Plan{
Name: "postgres-example",
Output: model.Output{
DatasetName: "author_books",
Verbose: true,
},
Connectors: []model.Connector{
{
Name: "books_db",
Type: model.ConnectorTypePostgres,
Connection: &model.PostgresConnectorConfig{
Host: "localhost",
Port: 5432,
Database: "books",
Username: "example_user",
Password: "example_password",
SSLMode: "disable",
},
},
{
Name: "authors_db",
Type: model.ConnectorTypePostgres,
Connection: &model.PostgresConnectorConfig{
Host: "localhost",
Port: 5432,
Database: "authors",
Username: "example_user",
Password: "example_password",
SSLMode: "disable",
},
},
},
Datasets: []model.Dataset{
{
Name: "books",
ConnectorName: "books_db",
Type: model.DatasetTypeSQL,
Options: &model.SQLDatasetOptions{
Query: "SELECT name as title, author, review FROM books",
Timeout: 30,
},
},
{
Name: "authors",
ConnectorName: "authors_db",
Type: model.DatasetTypeSQL,
Options: &model.SQLDatasetOptions{
Query: "SELECT id, slug, name, bio FROM authors",
Timeout: 30,
Dedupe: []string{"id", "slug"},
},
},
{
Name: "author_books",
ConnectorName: "federated",
Type: model.DatasetTypeSQL,
Options: &model.SQLDatasetOptions{
Query: `
SELECT a.name, b.title as title, b.review
FROM authors a
JOIN books b ON a.slug = b.author
`,
Timeout: 30,
Dedupe: []string{"id", "slug"},
},
Children: []model.DatasetChild{
{DatasetName: "authors"},
{DatasetName: "books"},
},
},
},
}
if err := plan.Validate(); err != nil {
log.Fatalf("invalid plan: %v", err)
}
resp, err := rt.ExecutePlan(context.Background(), model.ExecutePlanRequest{
Plan: plan,
})
if err != nil {
log.Fatal(err)
}
fmt.Println("Columns:", resp.Columns)
fmt.Printf("Rows:\n")
for _, row := range resp.Data {
fmt.Printf(" %v\n", row)
}
}- Queries two completely separate Postgres databases
- Loads them into the runtime
- Joins them using SQL
- Returns a unified result set
No ETL. No pipelines. Just declarative data access.
See
examples/postgresfor a runnable version using.env.
git clone https://github.com/kvatch-hub/kvatch-runtime
cd kvatch-runtime
cp examples/postgres/.env.example .env
go run ./examples/postgres- 🔗 Federated queries across multiple data sources
- 🧩 Pluggable connectors (API, Postgres, CSV, Google Sheets, etc.)
- ⚡ In-memory execution engine
- 🧱 Strongly typed runtime model
- 🛠 Built for extensibility
The packages intended for external use are:
pkg/runtimemodelconfigs
Everything under internal/ is implementation detail and may change without notice.
- Stable/primary:
postgres,sqlite,api,localfile,local_directory - Available:
googlesheet,git,s3,google_api - Special runtime-only connector:
federated
For early releases, treat non-primary connectors as evolving APIs.
- Track a crypto portfolio →
examples/crypto_portfolio - Query federated datasets using SQL →
examples/postgres
Kvatch aims to make querying distributed data as simple as writing SQL — without moving or duplicating it.
MIT License © 2026 James Wooltorton