fix: Primary key declaration#648
Open
vrkirillov wants to merge 12 commits into
Open
Conversation
Renamed macros in table materialization: 1. order_cols to order_by_cause 2. partition_cols to partition_by_clause
…re unspecified Replace single quotes with double quotes in order_by_clause macro Remove parentheses from MergeTree in order_by_clause macro
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 25ec4af. Configure here.
…able materialization
vrkirillov
commented
May 27, 2026
vrkirillov
left a comment
Contributor
Author
There was a problem hiding this comment.
fix recommendations in Cursor
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.

Summary
Checklist
Delete items not relevant to your PR:
Note
Medium Risk
Changes default DDL for MergeTree tables without
order_by(PK-only vsORDER BY (tuple())), which can affect physical layout and query performance for existing models.Overview
Adds MergeTree
primary_keymodel config (string or column list) so DDL can emitPRIMARY KEY (...)fortable,distributed_table, and seed materializations, with docs and YAML/SQL examples in the changelog.Refactors shared DDL helpers in
table.sql:make_columns, renamedorder_by_clause/partition_by_clause, andprimary_keybeforeorder by/partition by. When onlyprimary_keyis set (noorder_by), the adapter no longer forces defaultORDER BY (tuple()), matching ClickHouse’s ability to rely on the primary key for sorting.Integration tests assert
system.tablesprimary_keyandsorting_keyfor models with PK-only vs PK + explicitorder_by.Reviewed by Cursor Bugbot for commit c8c860d. Bugbot is set up for automated code reviews on this repo. Configure here.