Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed Jul 17, 2024
1 parent 739b023 commit 4db7f0a
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions pkg/statistics/handle/storage/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,25 +143,26 @@ func GenJSONTableFromStats(
}
jsonTbl.ExtStats = dumpJSONExtendedStats(tbl.ExtendedStats)
if colStatsUsage != nil {
jsonColStatsUsage := make([]*util.JSONPredicateColumn, 0)
// nilIfNil checks if the provided *time.Time is nil and returns a nil or its string representation accordingly.
nilIfNil := func(t *types.Time) *string {
if t == nil {
return nil
}
s := t.String()
return &s
}
jsonColStatsUsage := make([]*util.JSONPredicateColumn, 0, len(colStatsUsage))
for id, usage := range colStatsUsage {
jsonCol := &util.JSONPredicateColumn{
ID: id.ID,
}
if usage.LastUsedAt != nil {
// UTC
s := usage.LastUsedAt.String()
jsonCol.LastUsedAt = &s
}
if usage.LastAnalyzedAt != nil {
// UTC
s := usage.LastAnalyzedAt.String()
jsonCol.LastAnalyzedAt = &s
ID: id.ID,
LastUsedAt: nilIfNil(usage.LastUsedAt),
LastAnalyzedAt: nilIfNil(usage.LastAnalyzedAt),
}
jsonColStatsUsage = append(jsonColStatsUsage, jsonCol)
}
jsonTbl.PredicateColumns = jsonColStatsUsage
}

return jsonTbl, nil
}

Expand Down

0 comments on commit 4db7f0a

Please sign in to comment.