Skip to content

Commit

Permalink
Fix order of cluster and engine for create db
Browse files Browse the repository at this point in the history
  • Loading branch information
raubitsj committed Dec 11, 2024
1 parent 8091546 commit a7b6539
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_create_db_sql_replicated(mock_costs, migrator):

sql = migrator._create_db_sql("test_db")
expected = """
CREATE DATABASE IF NOT EXISTS test_db ENGINE=Replicated('/clickhouse/tables/test_db', '{shard}', '{replica}') ON CLUSTER test_cluster
CREATE DATABASE IF NOT EXISTS test_db ON CLUSTER test_cluster ENGINE=Replicated('/clickhouse/tables/test_db', '{shard}', '{replica}')
""".strip()
assert sql.strip() == expected

Expand Down
4 changes: 2 additions & 2 deletions weave/trace_server/clickhouse_trace_server_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ def _create_db_sql(self, db_name: str) -> str:
):
raise MigrationError(f"Invalid replicated path: {replicated_path}")

replicated_cluster = f" ON CLUSTER {self.replicated_cluster}"
replicated_engine = (
f" ENGINE=Replicated('{replicated_path}', '{{shard}}', '{{replica}}')"
)
replicated_cluster = f" ON CLUSTER {self.replicated_cluster}"

create_db_sql = f"""
CREATE DATABASE IF NOT EXISTS {db_name}{replicated_engine}{replicated_cluster}
CREATE DATABASE IF NOT EXISTS {db_name}{replicated_cluster}{replicated_engine}
"""
return create_db_sql

Expand Down

0 comments on commit a7b6539

Please sign in to comment.