Backport tenant-leading ClickHouse sort key + LowCardinality (2.4.x → 2.4.3)#127
Merged
Conversation
… (2.4.x) Targets the database-5 2.4.x maintenance line so Appwrite Cloud (locked to utopia-php/database 5 via server-ce) can consume it. The 2.5.0/2.6.0 releases require database ^6.0.0 and are unusable by cloud. Same logical change as #126: - setup() CREATE TABLE: tenant-leading ORDER BY (tenant, time, id) when sharedTables is enabled, otherwise (time, id); allow_nullable_key = 1 only emitted for shared tables (tenant is Nullable(UInt64)). - event/actorType/resourceType -> LowCardinality(String) and country -> LowCardinality(Nullable(String)) in CREATE TABLE column definitions only. - Live test testSharedTableSortKeyLeadsWithTenant asserts sorting_key leads with tenant. No projection/migration/getSortingKey logic; fresh-schema-only.
Greptile Summary
Confidence Score: 5/5The changes are focused on fresh ClickHouse schema creation and include targeted coverage for the shared-table sorting key behavior. The touched adapter logic matches the described backport scope, existing query behavior is unchanged, and the added live test covers the key schema invariant.
What T-Rex did
Reviews (1): Last reviewed commit: "Backport: lead ClickHouse audit sort key..." | Re-trigger Greptile |
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.
Why
Appwrite Cloud is locked to
utopia-php/database 5.*(via server-ce), so it cannot consume audit2.5.0/2.6.0, both of which requiredatabase ^6.0.0. This backports the tenant-leading ClickHouse sort-key work from #126 (released in 2.6.0) onto the2.4.xmaintenance line, which stays ondatabase 5.*.What
Same logical change as #126, adapted to the 2.4.2 adapter structure:
setup()'sCREATE TABLE:ORDER BY (tenant, time, id)whensharedTablesis enabled, otherwiseORDER BY (time, id).allow_nullable_key = 1appended toSETTINGSonly for shared tables (tenant isNullable(UInt64)).CREATE TABLEcolumn definitions only:event,actorType,resourceType→LowCardinality(String);country→LowCardinality(Nullable(String))(nullable wrapped inside).ClickHouseTest::testSharedTableSortKeyLeadsWithTenant()assertssystem.tables.sorting_keyleads withtenant(runs against the docker-compose ClickHouse in CI).No projection /
getSortingKey/ migration logic is introduced — the library stays fresh-schema-only. Index set andquery()visibility are unchanged.Verification
composer installresolvesutopia-php/database 5.0.0(database stays on 5.*).phpunit tests/Audit/QueryTest.php→ 11 passed.pint --test→ pass;phpstan analyse --level max src tests→ no errors.php -lclean on changed files. The live ClickHouse test passes in CI; locally it errors only on connection.Release
Should be released as 2.4.3.