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

Commit 304f8b7

Browse files
committed
Adapt more data types for doris
1 parent b68c888 commit 304f8b7

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

platform/model/metrics_aggregations/quantile.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ func (query Quantile) processResult(colName string, percentileReturnedByClickhou
117117
percentileIsNanOrInvalid = math.IsNaN(percentileTyped[0])
118118
percentile = percentileTyped[0]
119119
}
120+
case float64:
121+
// The data read out in apache doris is float64
122+
percentileAsArrayLen = 1
123+
percentileIsNanOrInvalid = math.IsNaN(percentileTyped)
124+
percentile = percentileTyped
120125
case []time.Time:
121126
percentileAsArrayLen = len(percentileTyped)
122127
if len(percentileTyped) > 0 {

platform/model/metrics_aggregations/quantile_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ func Test_processResult(t *testing.T) {
4141
{"", math.NaN(), nil},
4242
{"0", math.NaN(), nil},
4343
{0, math.NaN(), nil},
44-
{0.0, math.NaN(), nil},
44+
{0.0, 0, nil},
45+
{float64(1.0), 1.0, nil},
4546
{[]string{"1.0"}, math.NaN(), nil},
4647
{[]string{"1.0", "5"}, math.NaN(), nil},
4748
{[]any{"1.0", "5"}, math.NaN(), nil},

platform/model/typical_queries/hits.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ func (query Hits) addAndHighlightHit(hit *model.SearchHit, resultRow *model.Quer
200200
if valueAsString != nil {
201201
hit.Highlight[columnName] = query.highlighter.HighlightValue(fieldName, *valueAsString)
202202
}
203+
case int64:
204+
hit.Highlight[columnName] = query.highlighter.HighlightValue(fieldName, strconv.FormatInt(valueAsString, 10))
203205
case []string:
204206
for _, v := range valueAsString {
205207
hit.Highlight[columnName] = append(hit.Highlight[columnName], query.highlighter.HighlightValue(fieldName, v)...)

platform/parsers/elastic_query_dsl/aggregation_parser.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,17 @@ func (cw *ClickhouseQueryTranslator) parseFieldField(shouldBeMap any, aggregatio
282282

283283
func (cw *ClickhouseQueryTranslator) parseIntField(queryMap QueryMap, fieldName string, defaultValue int) int {
284284
if valueRaw, exists := queryMap[fieldName]; exists {
285-
if asFloat, ok := valueRaw.(float64); ok {
286-
return int(asFloat)
285+
switch v := valueRaw.(type) {
286+
case float64:
287+
return int(v)
288+
case string:
289+
if intValue, err := strconv.Atoi(v); err == nil {
290+
return intValue
291+
}
292+
logger.WarnWithCtx(cw.Ctx).Msgf("%s is a string but cannot be converted to int, value: %v. Using default: %d", fieldName, v, defaultValue)
293+
default:
294+
logger.WarnWithCtx(cw.Ctx).Msgf("%s is not an float64 or string, but %T, value: %v. Using default: %d", fieldName, valueRaw, valueRaw, defaultValue)
287295
}
288-
logger.WarnWithCtx(cw.Ctx).Msgf("%s is not an float64, but %T, value: %v. Using default: %d", fieldName, valueRaw, valueRaw, defaultValue)
289296
}
290297
return defaultValue
291298
}

0 commit comments

Comments
 (0)