duckOrch GitHub ↗

Embedded Python API

Use typed arguments with a DuckDB connection configured by your application.

View the Python source

DailyPartitionPlanner

Map application model IDs to registered daily assets on one connection.

  • __init__(self, connection: DuckDBPyConnection, models: Mapping[str, str])
  • pending(self, model_id: str, start: date, end: date) → list[date]

    Registered days in [start, end) whose latest attempt has not succeeded.

  • pending_ranges(self, model_id: str, start: date, end: date) → list[tuple[date, date]]

    Coalesce adjacent pending registered days into half-open ranges.

DateWindow

Half-open calendar date range.

  • start: date
  • end: date

PartitionGrain

  • DAY = 'day'
  • MONTH = 'month'
  • ALL = 'all'

RollingDependency

Days before and after an output date that its calculation reads.

  • lookback: int = 0
  • lookahead: int = 0

PlanStep

  • tenant_id: str
  • model_id: str
  • window: DateWindow
  • reason: str
  • parent_id: str | None
  • estimated_bytes: int | None

CoverageClaim

  • claim_id: UUID
  • model_id: str
  • generation: str
  • window: DateWindow

CoverageBatch

  • claims: tuple[CoverageClaim, ...]
  • generation(self)
  • window(self)

GenerationCoverage

Durable half-open work intervals on a host-owned, tenant-specific database.

  • __init__(self, connection: DuckDBPyConnection, models: Mapping[str, str])
  • enqueue(self, model_id: str, generation: str, requested: DateWindow) → list[CoverageClaim]

    Atomically reserve just the pieces not already queued or completed.

  • finish(self, claim: CoverageClaim, *, success: bool) → bool

    Keep successful coverage or release a failed reservation for retry.

  • batches(claims: list[CoverageClaim]) → list[CoverageBatch]

    Combine adjacent intervals from separate requests into one job.

  • settle(self, batch: CoverageBatch, succeeded: set[UUID]) → tuple[bool, ...]

    Commit successful portions and release failed portions in one transaction.

ChangeWindowPlanner

Read-side change plan for a host-registered calendar DAG. The caller supplies a tenant-specific graph and retained date horizon at construction. Use ALL when an edge has no established partition mapping.

  • __init__(self, dependencies: Mapping[str, Mapping[str, PartitionGrain | RollingDependency]], horizon: DateWindow)
  • affected(self, source_id: str, changed: DateWindow) → dict[str, tuple[DateWindow, ...]]

    Propagate one changed window to downstream models in topological order.

  • affected_many(self, changes: Mapping[str, Iterable[DateWindow]]) → dict[str, tuple[DateWindow, ...]]

    Propagate disjoint source changes and merge touching output intervals.

  • explain(self, changes: Mapping[str, Iterable[DateWindow]], *, tenant_id: str, bytes_per_day: Mapping[str, int] | None=None) → Iterator[PlanStep]

    Stream source and parent-edge evidence in dependency order.

ChangeLedger

Persist source corrections by revision in a tenant-scoped DuckDB file.

  • __init__(self, connection: DuckDBPyConnection, models: Mapping[str, str])
  • record(self, model_id: str, revision: str, changed: DateWindow) → bool

    Insert a source interval once and return whether it was new.

  • plan(self, revision: str, planner: ChangeWindowPlanner) → dict[str, tuple[DateWindow, ...]]

    Map the recorded source ranges to their downstream windows.

  • explain(self, revision: str, planner: ChangeWindowPlanner, *, tenant_id: str, bytes_per_day: Mapping[str, int] | None=None) → Iterator[PlanStep]

FileRevision

  • uri: str
  • version: str

FileIngestionLedger

Track immutable file revisions for one registered input on a tenant database.

  • __init__(self, connection: DuckDBPyConnection, input_id: str)
  • pending(self, files: list[FileRevision]) → list[FileRevision]

    Return distinct, unprocessed revisions in inventory order.

  • complete(self, files: list[FileRevision]) → int

    Confirm file revisions after their ingest output has committed.

QualityCheckSelector

Choose registered checks from changes to their model and column inputs.

  • __init__(self, checks: Mapping[str, Mapping[str, Iterable[str] | None] | None])
  • select(self, changes: Mapping[str, Iterable[str] | None]) → tuple[str, ...]

    None marks a whole-model change or a dependency with unknown columns.

ForeignKeyCheck

Count non-null child keys missing from a registered parent relation.

  • child: str
  • child_key: str
  • parent: str
  • parent_key: str
  • violation_count(self, connection: DuckDBPyConnection) → int

RowCountRule

  • minimum: int = 0
  • maximum: int | None = None

NullRule

  • column_id: str
  • maximum: int = 0

NumericRangeRule

  • column_id: str
  • minimum: float
  • maximum: float
  • allowed: int = 0

QualityObservation

  • check_id: str
  • observed: int
  • passed: bool

SharedQualityScan

Validate an interval against host-registered columns with one scan.

  • __init__(self, connection: DuckDBPyConnection, relation: str, *, date_column: str, columns: Mapping[str, str])
  • evaluate(self, window: DateWindow, checks: Mapping[str, RowCountRule | NullRule | NumericRangeRule]) → list[QualityObservation]

RevisionExample

  • key: int
  • kind: str
  • previous: dict | None
  • current: dict | None

RevisionComparison

  • added: int
  • removed: int
  • changed: int
  • unchanged: int
  • previous_duplicate_keys: int
  • current_duplicate_keys: int
  • previous_null_keys: int
  • current_null_keys: int
  • column_changes: dict[str, int]
  • examples: tuple[RevisionExample, ...]

RevisionDifference

Compare two compatible relations with a registered BIGINT key.

  • __init__(self, connection: DuckDBPyConnection, previous: str, current: str, *, key: str, columns: Mapping[str, str])
  • compare(self, *, example_limit: int=20) → RevisionComparison

ModelFingerprint

Hashes of executable inputs and the versions of referenced models.

  • definition: str
  • upstream_versions: tuple[tuple[str, str | None], ...]
  • macros: str
  • settings: str
  • engine: str
  • capture(cls, sql: str, *, engine_version: str, macros: Mapping[str, str] | None=None, settings: Mapping[str, str] | None=None, upstream_versions: Mapping[str, str | None] | None=None)
  • differences(self, other: 'ModelFingerprint') → tuple[str, ...]

FingerprintPlanner

Return invalidation reasons from consecutive executable model snapshots.

  • __init__(self, dependencies: Mapping[str, Iterable[str]])
  • plan(self, previous: Mapping[str, ModelFingerprint], current: Mapping[str, ModelFingerprint]) → dict[str, tuple[str, ...]]

FingerprintStore

Keep immutable named fingerprints in the tenant's DuckDB file.

  • __init__(self, connection: DuckDBPyConnection)
  • save(self, revision: str, models: Mapping[str, ModelFingerprint]) → None
  • load(self, revision: str) → dict[str, ModelFingerprint]

ReleaseModel

  • physical_version: str
  • contract: str

ReleasePlan

  • environment_id: UUID
  • revision: str
  • base_epoch: int
  • input_epoch: int

PublishedGeneration

  • revision: str
  • epoch: int
  • models: tuple[tuple[str, ReleaseModel], ...]
  • inputs: tuple[tuple[str, str], ...]

ReleaseNotification

  • event_id: UUID
  • environment: str
  • epoch: int
  • revision: str
  • kind: str

StaleReleasePlan

The active generation or source inputs changed since preparation.

    ReleaseRequestConflict

    A publication key was already used with a different request.

      GenerationCatalog

      Publish immutable checked manifests through one DuckDB transaction per environment.

      • __init__(self, connection: DuckDBPyConnection, environment: str, model_ids: set[str])
      • set_inputs(self, inputs: Mapping[str, str]) → None

        Record the currently visible source versions without changing the active release.

      • stage(self, revision: str, models: Mapping[str, ReleaseModel], *, inputs: Mapping[str, str], checks: Mapping[str, bool]) → None

        Record all already-prepared physical versions and their passed checks.

      • prepare(self, revision: str) → ReleasePlan
      • validate(self, plan: ReleasePlan) → None

        Verify the plan before applying work. Publication checks the same versions again.

      • publish(self, plan: ReleasePlan, *, request_key: str | None=None) → PublishedGeneration
      • rollback(self, revision: str, *, expected_epoch: int) → PublishedGeneration

        Repoint the active release to an already published manifest.

      • pending_notifications(self, *, limit: int) → list[ReleaseNotification]

        Read a bounded batch. The caller may deliver the same event again until ACK.

      • acknowledge_notifications(self, events: list[UUID]) → int

        Mark previously delivered IDs from this environment as acknowledged.

      • active(self) → PublishedGeneration | None
      • fork(self, target_environment: str) → 'GenerationCatalog'

        Create a trial environment pinned to the current immutable references.

      JsonType

      • INTEGER = ('BIGINT', ('BIGINT', 'UBIGINT'))
      • NUMBER = ('DOUBLE', ('BIGINT', 'UBIGINT', 'DOUBLE'))
      • TEXT = ('VARCHAR', ('VARCHAR',))
      • BOOLEAN = ('BOOLEAN', ('BOOLEAN',))

      JsonField

      • path: tuple[str, ...]
      • kind: JsonType

      ProjectedJson

      • values: dict[str, int | float | str | bool | None]
      • issues: dict[str, str]
      • source: str | None

      JsonProjector

      Project a host-registered set of JSON paths to typed DuckDB STRUCT fields.

      • __init__(self, connection: DuckDBPyConnection, fields: Mapping[str, JsonField], *, keep_source: bool=False)
      • project(self, documents: list[str]) → list[ProjectedJson]

        Expose missing, null, type and range issues without dropping a row.

      VariantEvent

      • event_id: str
      • kind: str
      • occurred_at: datetime
      • json_attributes: str

      ReadVariantEvent

      • event_id: str
      • kind: str
      • occurred_at: datetime
      • attributes: dict

      VariantEventLog

      Keep event keys in typed columns and tenant-specific attributes in VARIANT.

      • __init__(self, connection: DuckDBPyConnection, stream: str, *, promoted_text: str | None=None)
      • append(self, events: list[VariantEvent]) → None
      • read(self, kind: str, *, key: str | None=None, value: str | None=None) → list[ReadVariantEvent]

      ColumnType

      • BOOLEAN = 'BOOLEAN'
      • SMALLINT = 'SMALLINT'
      • INTEGER = 'INTEGER'
      • BIGINT = 'BIGINT'
      • HUGEINT = 'HUGEINT'
      • FLOAT = 'FLOAT'
      • DOUBLE = 'DOUBLE'
      • TEXT = 'VARCHAR'
      • DATE = 'DATE'
      • TIMESTAMP = 'TIMESTAMP'
      • INSTANT = 'TIMESTAMP WITH TIME ZONE'
      • JSON = 'JSON'

      ColumnContract

      • kind: ColumnType
      • nullable: bool = True

      SchemaViolation

      • column: str
      • kind: str
      • expected: str | bool | None
      • actual: str | bool | None

      RelationContract

      Check declared column names, types and nullability against DuckDB metadata.

      • __init__(self, columns: Mapping[str, ColumnContract], *, allow_extra: bool=True)
      • inspect(self, connection: DuckDBPyConnection, relation: str) → tuple[SchemaViolation, ...]

      ScheduledTask

      • tenant: str
      • depends_on: tuple[str, ...]
      • duration: int | None

      CriticalPathScheduler

      Prioritize ready tasks by estimated remaining path under tenant quotas.

      • __init__(self, tasks: Mapping[str, ScheduledTask], quotas: Mapping[str, int], *, default_duration: int=1)
      • ready(self, *, completed: set[str], running: set[str], slots: int) → tuple[str, ...]

        Return a deterministic dispatch order with no more than total slots.

      MembershipChange

      • key: int
      • previous_group: str | None
      • current_group: str | None

      GroupDelta

      Refresh region sums and row counts from the committed current relation.

      • __init__(self, connection: DuckDBPyConnection, source: str, target: str)
      • refresh(self, revision: str, changes: list[MembershipChange]) → int

        Rebuild the union of current and former groups for a revision.