diff --git a/platform/model/metrics_aggregations/quantile.go b/platform/model/metrics_aggregations/quantile.go index bf2be95dc..8cb6fb029 100644 --- a/platform/model/metrics_aggregations/quantile.go +++ b/platform/model/metrics_aggregations/quantile.go @@ -117,6 +117,11 @@ func (query Quantile) processResult(colName string, percentileReturnedByClickhou percentileIsNanOrInvalid = math.IsNaN(percentileTyped[0]) percentile = percentileTyped[0] } + case float64: + // The data read out in apache doris is float64 + percentileAsArrayLen = 1 + percentileIsNanOrInvalid = math.IsNaN(percentileTyped) + percentile = percentileTyped case []time.Time: percentileAsArrayLen = len(percentileTyped) if len(percentileTyped) > 0 { diff --git a/platform/model/metrics_aggregations/quantile_test.go b/platform/model/metrics_aggregations/quantile_test.go index 58ad4332b..86f6080c4 100644 --- a/platform/model/metrics_aggregations/quantile_test.go +++ b/platform/model/metrics_aggregations/quantile_test.go @@ -41,7 +41,8 @@ func Test_processResult(t *testing.T) { {"", math.NaN(), nil}, {"0", math.NaN(), nil}, {0, math.NaN(), nil}, - {0.0, math.NaN(), nil}, + {0.0, 0, nil}, + {float64(1.0), 1.0, nil}, {[]string{"1.0"}, math.NaN(), nil}, {[]string{"1.0", "5"}, math.NaN(), nil}, {[]any{"1.0", "5"}, math.NaN(), nil}, diff --git a/platform/model/typical_queries/hits.go b/platform/model/typical_queries/hits.go index 1628e403a..30d7372df 100644 --- a/platform/model/typical_queries/hits.go +++ b/platform/model/typical_queries/hits.go @@ -200,6 +200,8 @@ func (query Hits) addAndHighlightHit(hit *model.SearchHit, resultRow *model.Quer if valueAsString != nil { hit.Highlight[columnName] = query.highlighter.HighlightValue(fieldName, *valueAsString) } + case int64: + hit.Highlight[columnName] = query.highlighter.HighlightValue(fieldName, strconv.FormatInt(valueAsString, 10)) case []string: for _, v := range valueAsString { hit.Highlight[columnName] = append(hit.Highlight[columnName], query.highlighter.HighlightValue(fieldName, v)...) diff --git a/platform/parsers/elastic_query_dsl/aggregation_parser.go b/platform/parsers/elastic_query_dsl/aggregation_parser.go index 879424c02..d3d9fd8ca 100644 --- a/platform/parsers/elastic_query_dsl/aggregation_parser.go +++ b/platform/parsers/elastic_query_dsl/aggregation_parser.go @@ -282,10 +282,17 @@ func (cw *ClickhouseQueryTranslator) parseFieldField(shouldBeMap any, aggregatio func (cw *ClickhouseQueryTranslator) parseIntField(queryMap QueryMap, fieldName string, defaultValue int) int { if valueRaw, exists := queryMap[fieldName]; exists { - if asFloat, ok := valueRaw.(float64); ok { - return int(asFloat) + switch v := valueRaw.(type) { + case float64: + return int(v) + case string: + if intValue, err := strconv.Atoi(v); err == nil { + return intValue + } + logger.WarnWithCtx(cw.Ctx).Msgf("%s is a string but cannot be converted to int, value: %v. Using default: %d", fieldName, v, defaultValue) + default: + logger.WarnWithCtx(cw.Ctx).Msgf("%s is not an float64 or string, but %T, value: %v. Using default: %d", fieldName, valueRaw, valueRaw, defaultValue) } - logger.WarnWithCtx(cw.Ctx).Msgf("%s is not an float64, but %T, value: %v. Using default: %d", fieldName, valueRaw, valueRaw, defaultValue) } return defaultValue }