Skip to content

Commit

Permalink
Quickfix - accept size param to be string (#949)
Browse files Browse the repository at this point in the history
  • Loading branch information
trzysiek authored Nov 5, 2024
1 parent 5d19d94 commit 34ce6d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions quesma/queryparser/query_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,13 @@ func (cw *ClickhouseQueryTranslator) parseSize(queryMap QueryMap, defaultSize in
return defaultSize
} else if sizeAsFloat, ok := sizeRaw.(float64); ok {
return int(sizeAsFloat)
} else if sizeAsString, ok := sizeRaw.(string); ok {
if sizeAsInt, err := strconv.Atoi(sizeAsString); err == nil {
return sizeAsInt
} else {
logger.WarnWithCtx(cw.Ctx).Msgf("invalid size type: %T, value: %v. Expected int", sizeRaw, sizeRaw)
return defaultSize
}
} else {
logger.WarnWithCtx(cw.Ctx).Msgf("invalid size type: %T, value: %v. Expected float64", sizeRaw, sizeRaw)
return defaultSize
Expand Down
4 changes: 2 additions & 2 deletions quesma/testdata/aggregation_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ var AggregationTests = []AggregationTestCase{
LIMIT 1001`,
},
{ // [2]
TestName: "date_histogram",
TestName: "date_histogram + size as string",
QueryRequestJson: `
{
"_source": {
Expand All @@ -345,7 +345,7 @@ var AggregationTests = []AggregationTestCase{
"_count": "desc"
},
"shard_size": 25,
"size": 10
"size": "10"
}
}
},
Expand Down

0 comments on commit 34ce6d0

Please sign in to comment.