httk.store.backend.sql.layout¶
Versioned physical layout for httk.store.backend.sql.store.SqlStore.
Attributes¶
The persisted SqlStore layout protocol implemented by this package. |
|
Reserved key/value table holding the store protocol and entry declaration. |
|
Exceptions¶
A database does not exactly implement the current persisted store layout. |
|
A new open found an interrupted empty-store bulk ingest. |
Classes¶
One immutable configured entry family and its concrete records. |
|
The immutable normalized entry declaration of an initialized store. |
|
Dialect capabilities used by the SQL storage protocol. |
Functions¶
|
Serialize a normalized declaration in its exact deterministic persisted form. |
|
Resolve the hardcoded protocol facts for one supported dialect. |
|
Normalize a declaration and apply SQL physical-name validation. |
|
Normalize application-owned declarations and apply SQL physical-name validation. |
|
Merge registered and application-owned declarations and validate SQL names. |
|
Return SQLAlchemy metadata for all protocol-owned tables of |
|
Return the reserved protocol key/value table in |
|
Return application schema-object names mapped to their stable object kinds. |
|
Return application base-table names without SQLAlchemy reflection. |
|
Return the physical column names of |
|
Read the marker values, or return |
Module Contents¶
- class httk.store.backend.sql.layout.EntryFamilyLayout¶
One immutable configured entry family and its concrete records.
- class httk.store.backend.sql.layout.StorageLayout¶
The immutable normalized entry declaration of an initialized store.
- families: tuple[EntryFamilyLayout, Ellipsis]¶
- property entry_records: collections.abc.Mapping[type, tuple[type, Ellipsis]]¶
Configured family classes mapped to their ordered concrete record classes.
- property declaration: collections.abc.Mapping[str, tuple[str, Ellipsis]]¶
Configured stable family names mapped to their ordered stable record names.
- exception httk.store.backend.sql.layout.StorageLayoutUpgradeRequiredError(diff, *, hint=None)¶
Bases:
RuntimeErrorA database does not exactly implement the current persisted store layout.
diffis immutable and JSON-shaped. Its top-level keys are stable categories (currentlyprotocol,declarationandschema), so a caller can present a precise upgrade diagnostic without parsing the human-readable exception message. Thedeclarationcategory maps named aspect keys (metadata_keys,store_timestamps,write_profile,entry_declaration) to their own diagnostics, so several independent declaration mismatches are reported together; the exception message names the mismatched aspects.- Parameters:
diff (collections.abc.Mapping[str, object]) – The immutable JSON-shaped category-keyed difference.
hint (str | None) – An optional remediation appended to the message and exposed as
hint(e.g. that a purely additive schema change can be applied withupgrade=True).
- diff: collections.abc.Mapping[str, object]¶
- httk.store.backend.sql.layout.declaration_json(layout)¶
Serialize a normalized declaration in its exact deterministic persisted form.
- httk.store.backend.sql.layout.STORAGE_PROTOCOL_VERSION: Final = '2'¶
The persisted SqlStore layout protocol implemented by this package.
- httk.store.backend.sql.layout.METADATA_TABLE_NAME: Final = '_httk_store_metadata'¶
Reserved key/value table holding the store protocol and entry declaration.
- httk.store.backend.sql.layout.WRITE_PROFILE_VOCABULARY: Final¶
- exception httk.store.backend.sql.layout.StoreUnderConstructionError¶
Bases:
RuntimeErrorA new open found an interrupted empty-store bulk ingest.
Crash window for new SQLite/DuckDB opens: before the marker commits the old clean state remains accepted; after the marker and through ingest, finalize, or before marker clear the store is rejected; after clear it is accepted again. The marker is intentionally not a resume protocol.
ClickHouse marker residue is fail-closed: the default recovery is to drop the database and re-ingest. Clearing the marker is valid only after an operator has restored and verified the declared empty-store invariant.
- class httk.store.backend.sql.layout.BackendFacts¶
Dialect capabilities used by the SQL storage protocol.
- serial_stage_format: Literal['sqlite', 'duckdb-attach', 'parquet']¶
- parallel_shard_format: Literal['sqlite', 'parquet']¶
- metadata_backend: Literal['table', 'keepermap']¶
- system_catalog: Literal['sqlite', 'duckdb', 'clickhouse', 'postgresql']¶
- stage_load: Literal['attach', 'duckdb-views', 'client-stream']¶
- finalize_map_maintenance: Literal['update', 'swap']¶
- httk.store.backend.sql.layout.backend_facts_for_dialect(dialect_name)¶
Resolve the hardcoded protocol facts for one supported dialect.
- httk.store.backend.sql.layout.normalize_entry_records(entry_records)¶
Normalize a declaration and apply SQL physical-name validation.
- httk.store.backend.sql.layout.normalize_entry_families(entry_families)¶
Normalize application-owned declarations and apply SQL physical-name validation.
- httk.store.backend.sql.layout.normalize_entry_declaration(entry_records, entry_families)¶
Merge registered and application-owned declarations and validate SQL names.
- httk.store.backend.sql.layout.expected_metadata(layout, *, store_timestamps=True)¶
Return SQLAlchemy metadata for all protocol-owned tables of
layout.
- httk.store.backend.sql.layout.metadata_table_for(metadata)¶
Return the reserved protocol key/value table in
metadata.
- httk.store.backend.sql.layout.actual_schema_objects(connection)¶
Return application schema-object names mapped to their stable object kinds.
The DuckDB SQLAlchemy inspector presently routes column inspection through a PostgreSQL catalogue relation DuckDB does not expose, so the whole layout path intentionally uses the dialect catalogues directly.
- httk.store.backend.sql.layout.actual_table_names(connection)¶
Return application base-table names without SQLAlchemy reflection.
- httk.store.backend.sql.layout.actual_columns(connection, table_name)¶
Return the physical column names of
table_namewithout SQLAlchemy reflection.The DuckDB SQLAlchemy inspector routes column inspection through a PostgreSQL catalogue relation DuckDB does not expose (see
actual_schema_objects()), so this reads the dialect catalogues directly.
- httk.store.backend.sql.layout.read_store_metadata(connection)¶
Read the marker values, or return
Nonewhen no metadata table exists.