feat: production-table DDL (PARTITION/TTL/INDEX/SETTINGS) + parametrised DateTime64#8
Open
brentrager wants to merge 4 commits into
Open
feat: production-table DDL (PARTITION/TTL/INDEX/SETTINGS) + parametrised DateTime64#8brentrager wants to merge 4 commits into
brentrager wants to merge 4 commits into
Conversation
…parametrised DateTime64
Adds the structural DDL knobs the SmooAI observability + audit ClickHouse tables
need so the Rust kit can express the real production schema — it previously
modeled only name/columns/engine/order_by, which couldn't represent any of the
o11y tables (all use PARTITION BY; traces/logs use TTL/INDEX/SETTINGS; audit uses
DateTime64 with an explicit timezone). Per the kit principle, the gap lands in
the crate, not app code.
- TableSpec + FlexibleConfig gain partition_by / ttl / indexes / settings.
- to_create_table_sql renders INDEX lines (inside the column parens), PARTITION
BY (between ENGINE and ORDER BY), TTL (DateTime64 ttl column auto-wrapped in
toDateTime()), and SETTINGS — fully backward-compatible when all are empty/None.
- New IndexSpec / TtlSpec / TtlMove types. Safety posture: partition_by, index
expression/type, ttl intervals/volume, and settings values are app-controlled
raw fragments (like engine); only identifiers (table/column/index name, ttl
column, order_by) are validated, and ttl/order_by columns must be real columns.
- ColumnTypeSpec::DateTime64 { datetime64: DateTime64Spec } with validated
precision (0..=9) + IANA-charset timezone; bare "DateTime64" still renders (3).
- Version 0.1.0 -> 0.2.0. +12 tests (45 -> 51 unit), fmt/clippy clean.
Consumed by SmooAI/smooai SMOODEV-2115 (observability_logs/observability_traces
in api-prime, audit_log_events in audit-worker).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 8b40af1 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Rust kit's
TableSpecmodeled onlyname / columns / engine / order_by, so it could not express any of the SmooAI production observability/audit ClickHouse tables: all usePARTITION BY;observability_traces/observability_logsuseTTL+ secondaryINDEXes +SETTINGS;audit_log_eventsusesDateTime64(3, 'UTC')(explicit timezone). Per the kit principle — a gap lands in the crate, not app code — this adds the missing DDL surface so the kit can be adopted inrust/api-prime+rust/audit-worker(SmooAI/smooai SMOODEV-2115).Changes
TableSpec+FlexibleConfiggainpartition_by: Option<String>,ttl: Option<TtlSpec>,indexes: Vec<IndexSpec>,settings: Vec<(String, String)>.to_create_table_sqlrendersINDEXlines (inside the column parens),PARTITION BY(betweenENGINEandORDER BY),TTL(aDateTime64ttl column is auto-wrapped intoDateTime(...)), andSETTINGS— backward-compatible: a spec with all-empty/None knobs renders the exact legacy output.IndexSpec/TtlSpec/TtlMovetypes.ColumnTypeSpec::DateTime64 { datetime64: DateTime64Spec }with validated precision (0..=9) + IANA-charset timezone; bare"DateTime64"still rendersDateTime64(3).0.1.0→0.2.0.Safety posture
Only identifiers are validated (table/column/index names,
ttlcolumn,order_by— and ttl/order_by must be real columns).partition_by, indexexpression/type_def, ttl intervals/volume, andsettingsvalues are app-controlled raw fragments (same stance asengine) — never sourced from untrusted input. UntrustedDateTime64precision/timezone IS validated before rendering.Verification
cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo test— all clean. 51 unit tests pass (+12), including a byte-for-byte reproduction of the liveobservability_tracesDDL. The 2 testcontainer integration tests run in CI (rust.yml).Release
Crate publish is the manual
publish-crate.yml(workflow_dispatch) after merge tomain— gated to a maintainer. The SmooAI/smooai SMOODEV-2115 PR consumes this via a temporary git/path patch until0.2.0is on crates.io.🤖 Generated with Claude Code