Skip to content

Commit 86e3c5a

Browse files
committed
fix clickhouse create table to use current syntax of the merge tree
1 parent a090657 commit 86e3c5a

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

pkg/targets/clickhouse/creator.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,16 @@ func createMetricsTable(conf *ClickhouseConfig, db *sqlx.DB, tableName string, f
137137

138138
sql := fmt.Sprintf(`
139139
CREATE TABLE %s (
140-
created_date Date DEFAULT today(),
141-
created_at DateTime DEFAULT now(),
142-
time String,
143-
tags_id UInt32,
144-
%s,
145-
additional_tags String DEFAULT ''
146-
) ENGINE = MergeTree(created_date, (tags_id, created_at), 8192)
140+
created_date Date DEFAULT today(),
141+
created_at DateTime DEFAULT now(),
142+
time String,
143+
tags_id UInt32,
144+
%s,
145+
additional_tags String DEFAULT ''
146+
) ENGINE = MergeTree()
147+
ORDER BY (tags_id, created_at)
148+
PARTITION BY created_date
149+
SETTINGS index_granularity = 8192
147150
`,
148151
tableName,
149152
strings.Join(columnsWithType, ","))
@@ -180,7 +183,10 @@ func generateTagsTableQuery(tagNames, tagTypes []string) string {
180183
"created_at DateTime DEFAULT now(),\n"+
181184
"id UInt32,\n"+
182185
"%s"+
183-
") ENGINE = MergeTree(created_date, (%s), 8192)",
186+
") ENGINE = MergeTree()\n"+
187+
"PARTITION BY created_date\n"+
188+
"ORDER BY (%s)\n"+
189+
"SETTINGS index_granularity = 8192",
184190
cols,
185191
index)
186192
}

0 commit comments

Comments
 (0)