-
Notifications
You must be signed in to change notification settings - Fork 140
Fix: persist docs for Replicated cluster setups #494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
emirkmo
wants to merge
2
commits into
ClickHouse:main
Choose a base branch
from
emirkmo:fix-persist-docs-for-cluster
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Note: for the added test to catch regressions in CI you should add the following to - name: Run HTTP tests on replicated cluster
env:
DBT_CH_TEST_CLUSTER: test_replica
DBT_CH_TEST_CLUSTER_MODE: True
run: |
PYTHONPATH="${PYTHONPATH}:dbt"
pytest tests/
# or just run the comment test:
# pytest tests/integration/adapter/clickhouse/test_clickhouse_comments.py |
7f99238
to
4841279
Compare
failure requires `test_replica` cluster to be used.
The previous version of this macro blended the `MODIFY COMMENT` command for the table comment with the `COMMENT COLUMN` commands for the column comments, inside the same `ALTER TABLE`. This combined syntax **does not work** with `ON CLUSTER`. (This was thought to be a clickhouse bug, but that bug is fixed and the behavior remains.) The revised macro now sends a separate `ALTER TABLE` for the table comment `MODIFY COMMENT`, and a separate one for all the `COMMENT COLUMN` commands. I've split it up into 2 helper macros that accomplish each task for maintainability. This also works on non-cluster setups so there is no need to further complicate it by combining table and column comment alterations into a single ALTER. `clickhouse__persist_docs` now runs the relation (table comment) helper macro if `persist_relations_docs()` is set and descriptions exist for the relation and the column comment helper macro if `persist_column_docs()` and columns are defined in the model. Additionally, the formatting was cleaned up for multiple column comments so that comments for a different column are not appearing on the same line. Just makes it easier to read in clickhouse/dbt logs. Example: It produced comments like: ```sql alter table <table> [ON CLUSTER] modify comment $dbt_comment_literal_block$<table comment> $dbt_comment_literal_block$, comment column `col1_name` $dbt_comment_literal_block$<column comment> $dbt_comment_lieteral_block$, comment column `col2_name` ... ``` A bit messy, but works on a single node. Although `ON CLUSTER` is correctly added, this syntax is incorrect and ONLY produces table and column comments for the initiator node. Now it does: ```sql alter table <table> [ON CLUSTER] modify comment $dbt_comment_literal_block$ <table comment> $dbt_comment_literal_block$ alter table <table> [ON CLUSTER] comment column `col1_name` $dbt_comment_literal_block$<column multi linecomment>$dbt_comment_literal_block$, comment column `col2_name` $dbt_comment$ <column comment>$dbt_comment$, ... ```
4841279
to
671f7d0
Compare
Tried to retrigger it for attention. Could I please get the workflows approved or a review? |
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
Fix persist docs for replicated cluster setups. (Solves #295)
Split persist docs macro into two alter statements to handle cases where on cluster wouldn't persist comments on other replicas.
Checklist
Delete items not relevant to your PR:
Note for maintainers
Note that current github integrations tests do not use the cluster
test_replica
and hence didn't see the issue. The added tests only fail & pass usingtest_replica
cluster (i.e. replicated (and sharded if needed) cluster setups).Explanation
The previous version of this macro blended the
MODIFY COMMENT
command for the table comment with theCOMMENT COLUMN
commands for the column comments, inside the sameALTER TABLE
.This combined syntax does not work with
ON CLUSTER
for replicated setups. (This was thought to be a clickhouse bug, but that bug is fixed and the behavior remains.)The revised macro now sends a separate
ALTER TABLE
for the table commentMODIFY COMMENT
, and a separate one for all theCOMMENT COLUMN
commands.I've split it up into 2 helper macros that accomplish each task for maintainability. This also works on non-cluster setups so there is no need to further complicate it by combining table and column comment alterations into a single ALTER.
clickhouse__persist_docs
now runs the relation (table comment) helper macro, ifpersist_relations_docs()
is set and descriptions exist for the relation, and runs the column comment helper macro ifpersist_column_docs()
is set and columns are defined in the model.Additionally, the formatting was cleaned up for multiple column comments so that comments for a different column are not appearing on the same line. Just makes it easier to read in clickhouse/dbt logs.
Example:
Previous macro produced comments like:
A bit messy, but works on a single node.
Although
ON CLUSTER
is correctly added, this syntax is incorrect in a replicated setup and ONLY produces table and column comments for the initiator node. Now it does:Edit: Removed dev test leftovers.
Fixes: #295