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 backend pipeline aggregation query parsing and data frame building #168

Merged
merged 5 commits into from
May 22, 2023

Conversation

fridgepoet
Copy link
Member

@fridgepoet fridgepoet commented May 12, 2023

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #154

Special notes
I still notice an issue with the time series labels are being duplicated. #178
Screenshot 2023-05-12 at 16 42 45

@github-actions
Copy link

github-actions bot commented May 12, 2023

Backend code coverage report for PR #168

Plugin Main PR Difference
opensearch 77.9% 78.6% .7%

@github-actions
Copy link

Frontend code coverage report for PR #168
No changes

@github-actions
Copy link

github-actions bot commented May 12, 2023

Levitate is-compatible report:

🔍 Resolving @grafana/data@latest...
🔍 Resolving @grafana/ui@latest...
🔍 Resolving @grafana/runtime@latest...
🔍 Resolving @grafana/e2e-selectors@latest...

🔬 Checking compatibility between ./src/module.ts and @grafana/data@9.5.2...
✔ Found @grafana/data version 9.0.2 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/ui@9.5.2...
✔ Found @grafana/ui version 9.0.2 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/runtime@9.5.2...
✔ Found @grafana/runtime version 9.0.2 locally

🔬 Checking compatibility between ./src/module.ts and @grafana/e2e-selectors@9.5.2...
✔ Found @grafana/e2e-selectors version 9.0.2 locally

✔️ ./src/module.ts appears to be compatible with @grafana/data,@grafana/ui,@grafana/runtime,@grafana/e2e-selectors

@fridgepoet fridgepoet force-pushed the change-pipeline-aggregation branch from 1e1e900 to 53fa1dc Compare May 17, 2023 15:51
@fridgepoet fridgepoet changed the base branch from main to test-response-parser May 17, 2023 15:52
@fridgepoet fridgepoet force-pushed the change-pipeline-aggregation branch 2 times, most recently from da00e24 to 4ed743a Compare May 17, 2023 15:59
@fridgepoet fridgepoet changed the title WIP Fix backend pipeline aggregation query parsing and data frame building May 17, 2023
@fridgepoet fridgepoet force-pushed the change-pipeline-aggregation branch from 4ed743a to 9093797 Compare May 18, 2023 08:16
Base automatically changed from test-response-parser to main May 18, 2023 15:39
@fridgepoet fridgepoet force-pushed the change-pipeline-aggregation branch from 2baf2ea to e522eea Compare May 18, 2023 17:49
@fridgepoet fridgepoet marked this pull request as ready for review May 18, 2023 18:09
@fridgepoet fridgepoet requested a review from a team as a code owner May 18, 2023 18:09
@fridgepoet fridgepoet requested review from iwysiu and sarahzinger and removed request for a team May 18, 2023 18:09
Copy link
Contributor

@iwysiu iwysiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I tested it with the reported bug and it works now.

Its not a priority, but I wonder if it would make sense in a future commit to refactor the response_parser.go code to not use the null.Float object to make the syntax more similar

@@ -149,6 +150,20 @@ func (h *luceneHandler) processQuery(q *Query) error {
return nil
}

func getPipelineAggField(m *MetricAgg) string {
// From https://github.com/grafana/grafana/pull/60337
// In frontend we are using Field as pipelineAggField
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't know if we need to copy the todo comment (I'm assuming that if it's this old we decided that it was fine)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like littering comments either, but in this case if that's alright for you, maybe we should leave this one for now.
We don't yet know the overall impact of this change and I know some tests are still using the old PipelineAggregate input.

I think to remove this function and this comment we should make a decision to deprecate the MetricAgg "PipelineAggregate" field and systematically use Field to get the pipeline aggregate field.

The original issue is "only" about 5 months old -- I think eventually we will clean out a number of comments in this repo and we could include cleaning out this one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I know it's not the point of this pr, but would you mind removing the m := m on line 85 while we're in here)

Copy link
Contributor

@idastambuk idastambuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clicked around, looks good. Great job on this!

I also see the problem with duplicated labels. I think it's a good idea to open a ticket for this

@@ -588,6 +608,25 @@ func (rp *responseParser) getMetricName(metric string) string {
return metric
}

func castToFloat(j *simplejson.Json) *float64 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The originally-used castToNullFloat function below uses an underlying standard library type sql.NullFloat64 which is also a way to distinguish between something "null/nil" or with a float64 value. In this case, we can also just use a *float64 type to distinguish between "nil" and float64 and there is no strong reason to use an imported type for that.

Here's a similar discussion: https://stackoverflow.com/questions/33458439/using-sql-nullfloat64-vs-float64-in-golang

In Elasticsearch I noticed they moved towards *float64 so I copied that; I think that in further refactors the castToNullFloat will no longer be used.

@@ -149,6 +150,20 @@ func (h *luceneHandler) processQuery(q *Query) error {
return nil
}

func getPipelineAggField(m *MetricAgg) string {
// From https://github.com/grafana/grafana/pull/60337
// In frontend we are using Field as pipelineAggField
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like littering comments either, but in this case if that's alright for you, maybe we should leave this one for now.
We don't yet know the overall impact of this change and I know some tests are still using the old PipelineAggregate input.

I think to remove this function and this comment we should make a decision to deprecate the MetricAgg "PipelineAggregate" field and systematically use Field to get the pipeline aggregate field.

The original issue is "only" about 5 months old -- I think eventually we will clean out a number of comments in this repo and we could include cleaning out this one.

@fridgepoet fridgepoet merged commit b4a6f15 into main May 22, 2023
5 checks passed
@fridgepoet fridgepoet deleted the change-pipeline-aggregation branch May 22, 2023 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expressions following pipeline aggregations (derivative) result in Query Error: 500
3 participants