Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/logretention/clickhouse_ttl.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (c *ClickHouseTTL) alterTableTTL(ctx context.Context, tableName, timeColumn
if ttlDays == 0 {
query = fmt.Sprintf("ALTER TABLE %s REMOVE TTL", tableName)
} else {
query = fmt.Sprintf("ALTER TABLE %s MODIFY TTL %s + INTERVAL %d DAY", tableName, timeColumn, ttlDays)
query = fmt.Sprintf("ALTER TABLE %s MODIFY TTL toDateTime(%s) + INTERVAL %d DAY", tableName, timeColumn, ttlDays)
}

return c.conn.Exec(ctx, query)
Expand Down
8 changes: 4 additions & 4 deletions internal/logretention/clickhouse_ttl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func TestClickHouseTTL_ApplyTTL(t *testing.T) {
deploymentID: "",
ttlDays: 30,
wantQueries: []string{
"ALTER TABLE events MODIFY TTL event_time + INTERVAL 30 DAY",
"ALTER TABLE attempts MODIFY TTL attempt_time + INTERVAL 30 DAY",
"ALTER TABLE events MODIFY TTL toDateTime(event_time) + INTERVAL 30 DAY",
"ALTER TABLE attempts MODIFY TTL toDateTime(attempt_time) + INTERVAL 30 DAY",
},
wantQueryCount: 2,
},
Expand All @@ -58,8 +58,8 @@ func TestClickHouseTTL_ApplyTTL(t *testing.T) {
deploymentID: "dpm_001",
ttlDays: 7,
wantQueries: []string{
"ALTER TABLE dpm_001_events MODIFY TTL event_time + INTERVAL 7 DAY",
"ALTER TABLE dpm_001_attempts MODIFY TTL attempt_time + INTERVAL 7 DAY",
"ALTER TABLE dpm_001_events MODIFY TTL toDateTime(event_time) + INTERVAL 7 DAY",
"ALTER TABLE dpm_001_attempts MODIFY TTL toDateTime(attempt_time) + INTERVAL 7 DAY",
},
wantQueryCount: 2,
},
Expand Down
Loading