Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 2273237

Browse files
committed
fix
1 parent a85240b commit 2273237

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

platform/model/bucket_aggregations/date_histogram.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -222,21 +222,7 @@ func (query *DateHistogram) generateSQLForCalendarInterval() model.Expr {
222222
}
223223

224224
func (query *DateHistogram) getKey(row model.QueryResultRow) int64 {
225-
value := row.Cols[len(row.Cols)-2].Value
226-
switch v := value.(type) {
227-
case int64:
228-
return v
229-
case string:
230-
val, err := strconv.ParseInt(v, 10, 64)
231-
if err != nil {
232-
logger.Error().Msgf("string conver to int64 failed %T", v)
233-
return 0
234-
}
235-
return val
236-
default:
237-
logger.Error().Msgf("unsupported key type: %T", v)
238-
return 0
239-
}
225+
return extractRowValue(row)
240226
}
241227

242228
func (query *DateHistogram) Interval() (interval time.Duration, ok bool) {
@@ -430,6 +416,10 @@ func (qt *DateHistogramRowsTransformer) Transform(ctx context.Context, rowsFromD
430416
}
431417

432418
func (qt *DateHistogramRowsTransformer) getKey(row model.QueryResultRow) int64 {
419+
return extractRowValue(row)
420+
}
421+
422+
func extractRowValue(row model.QueryResultRow) int64 {
433423
value := row.Cols[len(row.Cols)-2].Value
434424
switch v := value.(type) {
435425
case int64:

0 commit comments

Comments
 (0)