Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: percentile operator bug in limit queries #3205

Closed
wants to merge 6 commits into from

Conversation

makeavish
Copy link
Member

close(#3204)

@github-actions github-actions bot added the bug Something isn't working label Jul 26, 2023
@makeavish makeavish marked this pull request as ready for review July 26, 2023 10:35
@makeavish makeavish requested a review from srikanthccv as a code owner July 26, 2023 10:35
@srikanthccv
Copy link
Member

Please help me understand why templating is needed here

@makeavish
Copy link
Member Author

Please help me understand why templating is needed here

If user uses % in the filter query then fmt.Sprintf was failing as % was treated as variable insertion operator. We could have escaped the characters but that could have more code changes. So used templates.

@srikanthccv
Copy link
Member

I do not think templating should be used because we need to make more code changes. What more changes are we talking about? There is one ClickHouseFormattedValue which should take of it.

@makeavish
Copy link
Member Author

I do not think templating should be used because we need to make more code changes. What more changes are we talking about? There is one ClickHouseFormattedValue which should take of it.

Apart from filter % can occur at multiple places, what if % is present in a key? So the cases keeps on increasing.
Using Template was safest bet for future changes or such scenarios.

@srikanthccv
Copy link
Member

Apart from filter % can occur at multiple places, what if % is present in a key? So the cases keeps on increasing

This is very unlikely. I don't think that justifies it. Assume such a key exists for the sake of argument. Does this fix solve all the issues? This is simply checking specific limit cases.

@makeavish
Copy link
Member Author

Apart from filter % can occur at multiple places, what if % is present in a key? So the cases keeps on increasing

This is very unlikely. I don't think that justifies it. Assume such a key exists for the sake of argument. Does this fix solve all the issues? This is simply checking specific limit cases.

In cases where we are using limit, it won't be a reproducible but template doesn't fix other such possible cases. We can use template everywhere to avoid the issues.

@srikanthccv
Copy link
Member

My point is that issue arose because of a special character, and it should be escaped. The idea of templatizing the whole query builder is a new effort from scratch; having seen the builder code, I think it will turn out to be a net negative and (most likely) will not fix the special character problems. I do not think we should introduce a templating here, and "mode code changes" is not a justifiable reason. I can think of many cases where not escaping is the source of bugs (try level = 'info in logs or something similar in traces or metrics). I do not want this PR to fix all potential such issues but escaping is the way to go, and it should start with this. I am open here others' thoughts on this.

// @nityanandagohain @rkssisodiya @ankitnayan

@ankitnayan
Copy link
Collaborator

There must be many golang projects that deal with the same issue. It would be wise to look into a few of them and get inspiration. @makeavish please post your findings

@makeavish
Copy link
Member Author

makeavish commented Aug 4, 2023

Other projects use DB library query parameters methods instead of manual escaping. We should also use clickhouse named parameters. We are already using clickhouse named parameters for getFilteredSpan function in reader.go.

@makeavish
Copy link
Member Author

Closing this as we will go ahead with using clickhouse named operators: #3345

@makeavish makeavish closed this Dec 26, 2023
@makeavish makeavish deleted the fix/percentile-operator-support branch December 26, 2023 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query builder breaks with percentile operator in where clause when used with limit
4 participants