wadjet

package
v0.18.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package wadjet provides the public embeddable API for Wadjet.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertValue

func ConvertValue(s string, typ parquet.TypeID) (any, error)

convertValue converts a string value from the parser to the appropriate Go type based on the target column's type. ConvertValue converts a string value to the appropriate Go type for a given Parquet type.

Types

type ColumnMeta

type ColumnMeta struct {
	Name      string
	TypeName  string         // Wadjet type name (e.g., "INT64", "STRING")
	TypeID    parquet.TypeID // Wadjet type ID
	Nullable  bool
	Precision int // DECIMAL: declared max digits
	Scale     int // DECIMAL: declared digits after the point
	// WireUnconstrained is true for a DECIMAL column produced by an
	// aggregate function (MIN/MAX/MIN_BY/MAX_BY/SUM/AVG and any other
	// DECIMAL-producing aggregate): Precision/Scale above still carry the
	// real declaration for callers that want it, but PostgreSQL's own wire
	// protocol reports typmod -1 ("unconstrained numeric") for any such
	// column — verified against live postgres:17-alpine's \gdesc, which
	// keeps a real typmod only for a BARE column reference. pgTypeMod
	// treats this the same as Precision <= 0 (FIX 2, #457/#458 fold-in).
	WireUnconstrained bool
}

ColumnMeta describes a result column's type information.

Precision and Scale are the DECLARATION, not the value: a bare TypeID is not a type for a DECIMAL, and the pgwire layer needs them to fill RowDescription's type modifier — PostgreSQL packs a numeric's precision and scale there, and it is where a JDBC or ODBC client reads ResultSetMetaData.getPrecision()/getScale() from. Sending the constant -1 declares an unconstrained numeric, so a tool that sizes a display column or round-trips DDL from a result set got it wrong for every DECIMAL(p,s) column (#454). They are zero for every other type.

type Config

type Config struct {
	Store        objstore.Store
	Bucket       string
	Logger       *slog.Logger
	MetaKV       catalog.MetaKV // optional: NATS KV for production, nil = in-memory
	MemoryBudget int64          // per-query memory budget in bytes (0 = unlimited)
	SpillDir     string         // directory for spill-to-disk files (empty = os temp dir)
	AuthProvider *auth.Provider // optional: enables ABAC enforcement at query level
	// SortMergeJoinBytes routes inner equi-joins whose sides BOTH exceed this
	// estimated size through the sort-merge join instead of the hash join
	// (docs/design/sort-merge-join.md). 0 = disabled (default).
	SortMergeJoinBytes int64
	// LateMaterialization emits inner/left hash-join output as view
	// (dictionary) columns with the gather deferred to first touch
	// (docs/design/late-materialization.md). Off by default.
	LateMaterialization bool
	// BushyJoinReorder lets the cost-based join reorder emit bushy plans
	// when strictly cheaper than every left-deep order
	// (docs/design/bushy-join-cbo.md). PROCESS-WIDE: the logical optimizer
	// has no per-query config surface, so Open stores this into a package
	// flag shared by every DB in the process. Off by default.
	BushyJoinReorder bool
	// EnableAlerts turns on the CREATE ALERT scheduler in embedded mode.
	// When true, Open() creates a Scheduler that evaluates alerts on cadence.
	EnableAlerts bool
}

Config holds configuration for creating a DB instance.

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB is the main entry point for embedded usage of Wadjet.

func Open

func Open(ctx context.Context, cfg Config) (*DB, error)

Open creates and initializes a new Wadjet database.

func (*DB) Catalog

func (db *DB) Catalog() *catalog.Catalog

Catalog returns the underlying catalog for advanced usage.

func (*DB) Close

func (db *DB) Close()

Close shuts down any background goroutines started by Open (e.g. alert scheduler). It is safe to call Close multiple times.

func (*DB) CreateTable

func (db *DB) CreateTable(ctx context.Context, name string, schema parquet.Schema, partitionKeys []string) error

CreateTable creates a new table with the given schema and partition keys.

func (*DB) DropTable

func (db *DB) DropTable(ctx context.Context, name string) error

DropTable removes a table from the catalog.

func (*DB) Execute

func (db *DB) Execute(ctx context.Context, sql string) (res *ExecResult, err error)

Execute runs a DML statement (INSERT/UPDATE/DELETE) and returns the result.

func (*DB) ListTables

func (db *DB) ListTables(ctx context.Context) ([]string, error)

ListTables returns all table names.

func (*DB) NewIngester

func (db *DB) NewIngester(tableName string, schema parquet.Schema, partitionKeys []string, cfg ingest.Config) *ingest.Ingester

NewIngester creates a micro-batch ingester for the given table.

func (*DB) Query

func (db *DB) Query(ctx context.Context, sql string) (res *QueryResult, err error)

Query executes a SQL query and returns the results.

func (*DB) SetAuthProvider

func (db *DB) SetAuthProvider(p *auth.Provider)

SetAuthProvider sets the auth provider for ABAC enforcement. This allows wiring auth after DB creation (e.g., when the provider depends on config reload).

func (*DB) Store

func (db *DB) Store() objstore.Store

Store returns the underlying object store.

type ExecResult

type ExecResult struct {
	RowsAffected int64
	Command      string // INSERT, UPDATE, DELETE
}

ExecResult contains the result of a DML operation (INSERT/UPDATE/DELETE).

type QueryResult

type QueryResult struct {
	Columns     []string
	ColumnMetas []ColumnMeta // typed column metadata (may be nil for introspection queries)
	Rows        []map[string]any
	Plan        string
}

QueryResult contains the result of a SQL query.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL