# v0.6.0 — Partitioned Tables, Safe DDL, and Circular Dependencies

> **Full technical details:** [v0.6.0.md-full.md](v0.6.0.md-full.md)

**Status: ✅ Released** | **Scope: Medium** (~4 weeks)

> Stream tables on partitioned source tables, idempotent "create or replace"
> DDL for simpler deployments, and the foundation for circular dependency
> handling in complex DAGs.

---

## What problem does this solve?

Many large PostgreSQL deployments use **table partitioning** to manage data
at scale — for example, one partition per month for time-series data. Stream
tables that read from partitioned tables need special treatment. Deployment
tools (like dbt and migration scripts) need safe, idempotent DDL that can be
run repeatedly without errors. And some advanced use cases require stream
tables that depend on each other in a cycle.

---

## Partitioned Source Tables

PostgreSQL **table partitioning** splits a large table into smaller physical
subtables based on a partition key. Queries against the parent table
automatically route to the right partitions.

pg_trickle now installs change-capture triggers on all partitions of a
partitioned source table, and correctly captures changes from any partition.
When new partitions are added (e.g. a new monthly partition), pg_trickle
detects this and installs triggers automatically.

*In plain terms:* if your log or events table is partitioned by date, stream
tables on it now work correctly without any special configuration.

---

## `create_or_replace_stream_table`

Deployment pipelines often need to run the same setup script multiple times
— during development, testing, and production rollout. Previously, running
`create_stream_table` twice on the same name would produce an error.

`create_or_replace_stream_table` works like a safe upsert: if the stream
table already exists with the same definition, it is left unchanged. If it
exists with a different definition, it is updated. If it does not exist, it
is created. This makes deployment scripts fully idempotent.

---

## Circular Dependency Foundation

Most dependency graphs are acyclic — A depends on B depends on C, with no
cycles. But some advanced use cases involve cycles: a stream table whose
result feeds back into its own source, or two stream tables that each
reference the other.

v0.6.0 lays the groundwork for handling these circular dependencies safely.
The scheduler can now detect cycles in the dependency graph and report them
clearly, rather than hanging or crashing. Full execution of circular DAGs
follows in v0.7.0.

---

## Edge Case Hardening

A set of edge cases in the differential engine were corrected:

- `COALESCE` and `NULLIF` in aggregate expressions
- Multiple `DISTINCT ON` columns
- Subqueries in `FROM` clauses that also appear as JOIN targets

---

## Scope

v0.6.0 extends pg_trickle's reach to partitioned tables (a common production
configuration), improves deployment ergonomics with idempotent DDL, and begins
the circular dependency story. Partitioned source support is the headline
feature for large-scale deployments.
