Documentation
¶
Overview ¶
Package wadjet provides the public embeddable API for Wadjet.
Index ¶
- func ConvertValue(s string, typ parquet.TypeID) (any, error)
- type ColumnMeta
- type Config
- type DB
- func (db *DB) Catalog() *catalog.Catalog
- func (db *DB) Close()
- func (db *DB) CreateTable(ctx context.Context, name string, schema parquet.Schema, ...) error
- func (db *DB) DropTable(ctx context.Context, name string) error
- func (db *DB) Execute(ctx context.Context, sql string) (res *ExecResult, err error)
- func (db *DB) ListTables(ctx context.Context) ([]string, error)
- func (db *DB) NewIngester(tableName string, schema parquet.Schema, partitionKeys []string, ...) *ingest.Ingester
- func (db *DB) Query(ctx context.Context, sql string) (res *QueryResult, err error)
- func (db *DB) SetAuthProvider(p *auth.Provider)
- func (db *DB) Store() objstore.Store
- type ExecResult
- type QueryResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 (*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) ListTables ¶
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) SetAuthProvider ¶
SetAuthProvider sets the auth provider for ABAC enforcement. This allows wiring auth after DB creation (e.g., when the provider depends on config reload).
type ExecResult ¶
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 is the result keyed by column NAME, and it is a convenience: a
// result may legally carry two columns of the same name (PostgreSQL
// answers `SELECT abs(a), abs(b)` with two columns called `abs`, and
// #513 made this engine agree), and a map cannot hold both — the LAST
// one wins and the earlier value is not represented. Columns still lists
// every column, so len(Rows[i]) < len(Columns) is how a caller detects
// it. Read RowValues when the values matter.
Rows []map[string]any
// RowValues is the same result POSITIONALLY, cells aligned with Columns,
// and it is populated ONLY when Rows would lose a value — that is, when
// two output columns share a name. nil means the names are unique and
// Rows is exact. Nothing that transports values (the pgwire DataRow
// path) may read Rows without consulting this first.
RowValues [][]any
Plan string
}
QueryResult contains the result of a SQL query.
func (*QueryResult) Cells ¶ added in v0.18.3
func (r *QueryResult) Cells(i int) []any
Cells returns row i positionally, whether or not the result needed RowValues: from RowValues when duplicate column names made the map lossy, and otherwise by looking each column up in Rows, which is exact there. Returns nil when i is out of range.