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

Commit b68c888

Browse files
authored
Adapt to string type time data (#1501)
Since the data is converted into string type in the data reading of doris, we need to process the string type specifically here. Related PR: https://github.com/QuesmaOrg/quesma/blob/main/platform/database_common/quesma_communicator.go#L228
1 parent 1d5d57c commit b68c888

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

platform/model/bucket_aggregations/date_histogram.go

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

224224
func (query *DateHistogram) getKey(row model.QueryResultRow) int64 {
225-
return row.Cols[len(row.Cols)-2].Value.(int64)
225+
return extractRowValue(row)
226226
}
227227

228228
func (query *DateHistogram) Interval() (interval time.Duration, ok bool) {
@@ -416,7 +416,25 @@ func (qt *DateHistogramRowsTransformer) Transform(ctx context.Context, rowsFromD
416416
}
417417

418418
func (qt *DateHistogramRowsTransformer) getKey(row model.QueryResultRow) int64 {
419-
return row.Cols[len(row.Cols)-2].Value.(int64)
419+
return extractRowValue(row)
420+
}
421+
422+
func extractRowValue(row model.QueryResultRow) int64 {
423+
value := row.Cols[len(row.Cols)-2].Value
424+
switch v := value.(type) {
425+
case int64:
426+
return v
427+
case string:
428+
val, err := strconv.ParseInt(v, 10, 64)
429+
if err != nil {
430+
logger.Error().Msgf("string conver to int64 failed %T", v)
431+
return 0
432+
}
433+
return val
434+
default:
435+
logger.Error().Msgf("unsupported key type: %T", v)
436+
return 0
437+
}
420438
}
421439

422440
func (qt *DateHistogramRowsTransformer) nextKey(key int64) int64 {

0 commit comments

Comments
 (0)