Skip to content

Add SQLAlchemy DDL support for missing replicated MergeTree engines#690

Merged
joe-clickhouse merged 1 commit intomainfrom
joe/687-feature-request-please-add-table-engines-such-as-replicatedreplacingmergetree
Mar 25, 2026
Merged

Add SQLAlchemy DDL support for missing replicated MergeTree engines#690
joe-clickhouse merged 1 commit intomainfrom
joe/687-feature-request-please-add-table-engines-such-as-replicatedreplacingmergetree

Conversation

@joe-clickhouse
Copy link
Copy Markdown
Contributor

@joe-clickhouse joe-clickhouse commented Mar 25, 2026

Summary

  • Adds missing table engine classes in clickhouse_connect/cc_sqlalchemy/ddl/tableengine.py for:
    • ReplicatedReplacingMergeTree
    • ReplicatedCollapsingMergeTree
    • ReplicatedVersionedCollapsingMergeTree
    • ReplicatedGraphiteMergeTree

so SQLAlchemy can render DDL for those engines.

  • Also fixes quoting for GraphiteMergeTree config sections which was a pre-existing issue.
  • Adds unit coverage for the new replicated engines plus the Graphite quoting behavior.

Closes #687

Checklist

Delete items not relevant to your PR:

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG

@joe-clickhouse
Copy link
Copy Markdown
Contributor Author

@copilot please review this PR.

Copy link
Copy Markdown

Copilot AI commented Mar 25, 2026

@copilot please review this PR.

Reviewed the PR — here's a summary:

All 6 tests pass, no security issues found.

What the changes do:

  • Adds ReplicatedReplacingMergeTree, ReplicatedCollapsingMergeTree, ReplicatedVersionedCollapsingMergeTree, and ReplicatedGraphiteMergeTree as new TableEngine subclasses, each following the existing arg/quoting pattern.
  • Fixes GraphiteMergeTree (and the new ReplicatedGraphiteMergeTree) to single-quote config_section as ClickHouse requires — e.g. GraphiteMergeTree('graphite_rollup') instead of GraphiteMergeTree(graphite_rollup).

Design notes:

  • The new classes extend TableEngine directly rather than ReplicatedMergeTree. This is intentional: the existing ReplicatedAggregatingMergeTree/ReplicatedSummingMergeTree are simple pass-throughs with no extra args, so they can inherit from ReplicatedMergeTree. The new classes each have an additional required engine argument (sign, version, or config_section), which forces a custom __init__ that must ultimately call TableEngine.__init__; chaining through ReplicatedMergeTree.__init__ would cause a double-init and double-processing of zk_path/replica.
  • ClickHouse Cloud style (no explicit zk_path/replica) works correctly: both are in optional_args, and the engine renders without them when omitted — e.g. ReplicatedReplacingMergeTree(ver_col) ORDER BY key.
  • sign / config_section are required: omitting them raises a clear ValueError, consistent with the existing CollapsingMergeTree pattern.

No changes needed — the implementation looks correct and complete.

@joe-clickhouse joe-clickhouse merged commit 5fd16eb into main Mar 25, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature request: please add table engines such as ReplicatedReplacingMergeTree

2 participants