NAME
DBIO::ClickHouse::Test::Schema - ClickHouse-native test schema for the DBIO::ClickHouse live suite
VERSION
version 0.900004
SYNOPSIS
my $schema = DBIO::ClickHouse::Test->init_schema;
my $rs = $schema->resultset('Hit');
DESCRIPTION
The test schema the DBIO::ClickHouse live suite deploys. It exists because the family-wide DBIO::Test::Schema cannot be the test schema for this driver -- see "WHY NOT DBIO::Test::Schema" -- and it is deliberately small: six sources, each of which is the only place one ClickHouse-specific decision gets deployed against a real server.
WHY NOT DBIO::Test::Schema
Every other driver distribution calls DBIO::Test->init_schema and gets DBIO::Test::Schema, the ~50-source fixture the family shares. DBIO::ClickHouse::Test does not, for four reasons in descending order of severity:
- 1. Its identity model is the one thing this driver documents as impossible. Nearly every source there has an integer
is_auto_incrementprimary key. ClickHouse has no sequences and no identity columns, so DBIO::ClickHouse::DDL emits no default for such a column and "last_insert_id" in DBIO::ClickHouse::Storage throws by design. A schema whose$rs->create({ name => 'x' })cannot work is not a fixture, it is a trap: the test would be exercising the error path while claiming to exercise the happy one. - 2. It carries nothing this driver deploys and everything it drops. Foreign keys, unique constraints and standalone indexes are all silently omitted by the DDL layer (
docs/adr/0004-no-foreign-keys.md), so the relationship-heavy half of that schema deploys to nothing at all -- while the part that would actually be interesting here,ENGINEand the MergeTree keys, is a concept it has no way to express. - 3. A deploy round trip has to be clean to be worth anything. The whole premise of DBIO::ClickHouse::Deploy is that a freshly deployed schema diffs empty against itself. That is a strong statement about
fortytables whose types were designed for SQLite, and a weak one about the handful of constructs ClickHouse actually has. Here it is the opposite: the schema is chosen so that a clean diff means every branch of the type map and everyclickhouse_tableclause survived the trip throughsystem.*. - 4. Live runs are rationed. ClickHouse has no in-memory mode, so every one of these tables is a real
CREATE TABLEon a real server that the maintainer started by hand for one serial run. Forty of them per test file, none of which asserts anything ClickHouse-specific, is not a cost this suite gets to spend.
The offline half of the suite is unaffected -- it never deploys anything.
THE SOURCES
DBIO::ClickHouse::Test::Schema::Hit -- plain
MergeTree, UUID key, the source the insert and mutation paths run against.DBIO::ClickHouse::Test::Schema::Snapshot --
ReplacingMergeTree(version), soFINALhas something to deduplicate.DBIO::ClickHouse::Test::Schema::Reading --
PARTITION BY, aPRIMARY KEYprefix of a two-column sorting key,LowCardinality.DBIO::ClickHouse::Test::Schema::Probe -- one column per branch of the DDL type map.
DBIO::ClickHouse::Test::Schema::Unsorted -- no primary key, hence
ORDER BY tuple().DBIO::ClickHouse::Test::Schema::HotHit -- a non-virtual view, the only
CREATE VIEWthis driver ever executes.
SEE ALSO
DBIO::ClickHouse::Test - deploys this schema into a scratch database
DBIO::Test::Schema - the family fixture this one replaces, and why
AUTHOR
DBIO Authors
COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.