fix: use correct column name for v4 tables (#5177)

This commit is contained in:
Srikanth Chekuri 2024-06-10 11:29:31 +05:30 committed by GitHub
parent cf54b5f9ec
commit 8a9c8031f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2378,13 +2378,18 @@ func (r *ClickHouseReader) SetTTL(ctx context.Context,
zap.L().Error("Error in inserting to ttl_status table", zap.Error(dbErr)) zap.L().Error("Error in inserting to ttl_status table", zap.Error(dbErr))
return return
} }
timeColumn := "timestamp_ms"
if strings.Contains(tableName, "v4") {
timeColumn = "unix_milli"
}
req := fmt.Sprintf( req := fmt.Sprintf(
"ALTER TABLE %v ON CLUSTER %s MODIFY TTL toDateTime(toUInt32(timestamp_ms / 1000), 'UTC') + "+ "ALTER TABLE %v ON CLUSTER %s MODIFY TTL toDateTime(toUInt32(%s / 1000), 'UTC') + "+
"INTERVAL %v SECOND DELETE", tableName, r.cluster, params.DelDuration) "INTERVAL %v SECOND DELETE", tableName, r.cluster, timeColumn, params.DelDuration)
if len(params.ColdStorageVolume) > 0 { if len(params.ColdStorageVolume) > 0 {
req += fmt.Sprintf(", toDateTime(toUInt32(timestamp_ms / 1000), 'UTC')"+ req += fmt.Sprintf(", toDateTime(toUInt32(%s / 1000), 'UTC')"+
" + INTERVAL %v SECOND TO VOLUME '%s'", " + INTERVAL %v SECOND TO VOLUME '%s'",
params.ToColdStorageDuration, params.ColdStorageVolume) timeColumn, params.ToColdStorageDuration, params.ColdStorageVolume)
} }
err := r.setColdStorage(context.Background(), tableName, params.ColdStorageVolume) err := r.setColdStorage(context.Background(), tableName, params.ColdStorageVolume)
if err != nil { if err != nil {