Skip to content

Commit

Permalink
stricter checks
Browse files Browse the repository at this point in the history
Signed-off-by: Shlomi Noach <[email protected]>
  • Loading branch information
shlomi-noach committed Dec 24, 2024
1 parent 26beaa4 commit 709815a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions go/vt/schemadiff/partitioning_analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ func TemporalRangePartitioningRetention(createTableEntity *CreateTableEntity, ex
return nil, err
}
switch {
case dt.IsZero():
case dt.IsZero() && analysis.FuncExpr != nil:
// Partition uses an intval, such as in:
// PARTITION p0 VALUES LESS THAN (738156)
expireIntval, err := applyFuncExprToDateTime(expireDatetime, analysis.FuncExpr)
Expand All @@ -588,13 +588,16 @@ func TemporalRangePartitioningRetention(createTableEntity *CreateTableEntity, ex
if intval <= expireIntval {
alterTable.PartitionSpec.Names = append(alterTable.PartitionSpec.Names, partition.Name)
}
default:
case !dt.IsZero():
// Partition uses a datetime, such as in these examples:
// - PARTITION p0 VALUES LESS THAN ('2021-01-01 00:00:00')
// - PARTITION p0 VALUES LESS THAN (TO_DAYS('2021-01-01'))
if dt.Compare(expireDatetime) <= 0 {
alterTable.PartitionSpec.Names = append(alterTable.PartitionSpec.Names, partition.Name)
}
default:
// Should never get here
return nil, fmt.Errorf("unsupported partitioning in table %s", createTableEntity.Name())
}
}
if len(alterTable.PartitionSpec.Names) == 0 {
Expand Down

0 comments on commit 709815a

Please sign in to comment.