Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.
Merged
Changes from 2 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
32 changes: 30 additions & 2 deletions platform/model/bucket_aggregations/date_histogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,21 @@ func (query *DateHistogram) generateSQLForCalendarInterval() model.Expr {
}

func (query *DateHistogram) getKey(row model.QueryResultRow) int64 {
return row.Cols[len(row.Cols)-2].Value.(int64)
value := row.Cols[len(row.Cols)-2].Value
Copy link
Contributor

@pdelewski pdelewski Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look below

switch v := value.(type) {
case int64:
return v
case string:
val, err := strconv.ParseInt(v, 10, 64)
if err != nil {
logger.Error().Msgf("string conver to int64 failed %T", v)
return 0
}
return val
default:
logger.Error().Msgf("unsupported key type: %T", v)
return 0
}
}

func (query *DateHistogram) Interval() (interval time.Duration, ok bool) {
Expand Down Expand Up @@ -416,7 +430,21 @@ func (qt *DateHistogramRowsTransformer) Transform(ctx context.Context, rowsFromD
}

func (qt *DateHistogramRowsTransformer) getKey(row model.QueryResultRow) int64 {
return row.Cols[len(row.Cols)-2].Value.(int64)
value := row.Cols[len(row.Cols)-2].Value
switch v := value.(type) {
case int64:
return v
case string:
val, err := strconv.ParseInt(v, 10, 64)
if err != nil {
logger.Error().Msgf("string conver to int64 failed %T", v)
return 0
}
return val
default:
logger.Error().Msgf("unsupported key type: %T", v)
return 0
}
}

func (qt *DateHistogramRowsTransformer) nextKey(key int64) int64 {
Expand Down
Loading