-
Notifications
You must be signed in to change notification settings - Fork 19
Report errors in queries better #2 (in parsing bucket aggregations) #1006
Conversation
1e433b7 to
348e0fe
Compare
Deploying quesma with
|
| Latest commit: |
0a07198
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9237ddaa.quesma.pages.dev |
| Branch Preview URL: | https://report-errors-in-queries-bet.quesma.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only very very minor style improvements in this file
a2b9125 to
11e7c61
Compare
11e7c61 to
d77bb30
Compare
cde08d8 to
df02efd
Compare
| } else { | ||
| logger.WarnWithCtx(cw.Ctx).Msgf("format specified for date range aggregation is not a string. Using empty. Querymap: %v", dateRange) | ||
| } | ||
| func (cw *ClickhouseQueryTranslator) parseDateRangeAggregation(aggregation *pancakeAggregationTreeNode, params QueryMap) (err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder about type signature? Why pass aggregation as argument, shouldn't we just return optional queryType?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, after reading later it become obvious why you did that way.
| filtersAggr = bucket_aggregations.NewFiltersEmpty(cw.Ctx) | ||
|
|
||
| filtersRaw, exists := queryMap["filters"] | ||
| func (cw *ClickhouseQueryTranslator) parseFilters(aggregation *pancakeAggregationTreeNode, params QueryMap) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar, here. Not sure if it's right to pass aggregation here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I understand. It explain later. Keep as ai.
| return false, fmt.Errorf("histogram is not a map, but %T, value: %v", histogramRaw, histogramRaw) | ||
| } | ||
| func (cw *ClickhouseQueryTranslator) pancakeTryBucketAggregation(aggregation *pancakeAggregationTreeNode, queryMap QueryMap) error { | ||
| aggregationHandlers := []struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nice!
old comment (motivation):
Our error messages for errors encountered while parsing query request isn't as good as Elastic's, I'll try to improve it here. (It's not that unimportant, with invalid query request where Elastic always fails with an error response, we often don't and e.g. return empty results, which might trick the user that queries went fine)
I think I'll split it into few PRs. This might be a good starting point for another one. (update: actually similar small improvement was already merged, but for pipeline aggregations)
new comment (what's been done):
There's really not much going on here.
Clue of this PR is to change our very ugly 400-line
func (cw *ClickhouseQueryTranslator) pancakeTryBucketAggregationfunction into something a bit nicer. And also report errors in more places, to be consistent with Elastic's behaviour.Quite a few style improvements that I automatically caught in the process, but only some trivial/very local ones, so extracting copy/paste used 5 times into 1 function, consistent naming across parsers of different aggregations, etc. (not much more).