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

Mimir Query Engine: Add instant-vector functions #8256

Merged
merged 40 commits into from
Jun 12, 2024

Conversation

jhesketh
Copy link
Contributor

@jhesketh jhesketh commented Jun 3, 2024

Start to add instant-vector functions.

  • Sets up a general structure for implementing instant-vector functions.
  • Implements histogram_count and histogram_sum
  • Implements acos

This is just the start to show the general structure. I'd like to get this approach verified and merged and then add the rest of the simpleFunc's (such as the basic maths operations) as a separate PR.

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

@jhesketh jhesketh changed the title Mimir Query Engine: Add basic instant-vector functions Mimir Query Engine: Add instant-vector functions Jun 3, 2024
Copy link
Contributor

@charleskorn charleskorn left a comment

Choose a reason for hiding this comment

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

Haven't reviewed the tests as you mentioned that you were still working on these

pkg/streamingpromql/operator/helper.go Outdated Show resolved Hide resolved
pkg/streamingpromql/operator/instant_vector_function.go Outdated Show resolved Hide resolved
pkg/streamingpromql/operator/instant_vector_function.go Outdated Show resolved Hide resolved
pkg/streamingpromql/operator/instant_vector_function.go Outdated Show resolved Hide resolved
pkg/streamingpromql/operator/instant_vector_function.go Outdated Show resolved Hide resolved
pkg/streamingpromql/functions/instant_vector.go Outdated Show resolved Hide resolved
pkg/streamingpromql/functions/instant_vector.go Outdated Show resolved Hide resolved
pkg/streamingpromql/operators/scalar.go Outdated Show resolved Hide resolved
pkg/streamingpromql/query.go Outdated Show resolved Hide resolved
pkg/streamingpromql/testdata/ours/native_histograms.test Outdated Show resolved Hide resolved
@jhesketh jhesketh marked this pull request as ready for review June 5, 2024 07:14
@jhesketh jhesketh requested a review from a team as a code owner June 5, 2024 07:14
pkg/streamingpromql/engine_test.go Outdated Show resolved Hide resolved
pkg/streamingpromql/operators/scalar.go Outdated Show resolved Hide resolved
pkg/streamingpromql/operators/scalar.go Outdated Show resolved Hide resolved
pkg/streamingpromql/query.go Show resolved Hide resolved
pkg/streamingpromql/operators/scalar.go Outdated Show resolved Hide resolved
pkg/streamingpromql/functions/common.go Outdated Show resolved Hide resolved
// Most of the functionality of functions is tested through the test scripts in
// pkg/streamingpromql/testdata.

func TestFunctionOverInstantVector(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this test trying to test? I'm not sure this is necessary - we can rely on the tests in the test scripts for the functions themselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't test anything extra that wouldn't be covered by the functional tests, but it is a unit test to confirm it does what we expect. It tests two things:

  • That both the MetadataFunc and SeriesDataFunc are called
  • That SeriesDataFunc is called once per series

Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't think this is necessary - we can confirm that the functions are called by observing their effects (eg. that the label name has been dropped or that the values returned are equal to acos(<value>)).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whilst very unlikely, it is possible that we confirm the effects correctly but do something like call SeriesDataFunc more than once.

We could make sure that is unlikely by writing functional tests (ie the test scripts) for functions that are non-idempotent, but then we run the risk of not maintaining that test correctly (eg we refactor or remove it in the future).

I agree it's very unlikely (maybe even impossible), and that this test (and the others) don't necessarily add much, but I also don't see it as a huge burden to keep the extra testing and assurances.

Worst case in regards to these (likely redundant) tests, is that we remove them later when we need to change the way something works internally and still satisfies the existing functional test.

pkg/streamingpromql/testdata/ours/native_histograms.test Outdated Show resolved Hide resolved
pkg/streamingpromql/testdata/ours/native_histograms.test Outdated Show resolved Hide resolved
pkg/streamingpromql/functions/common.go Outdated Show resolved Hide resolved
pkg/streamingpromql/functions.go Outdated Show resolved Hide resolved
pkg/streamingpromql/functions.go Outdated Show resolved Hide resolved
pkg/streamingpromql/functions.go Outdated Show resolved Hide resolved
pkg/streamingpromql/query.go Outdated Show resolved Hide resolved
pkg/streamingpromql/testdata/upstream/functions.test Outdated Show resolved Hide resolved
@@ -19,7 +19,7 @@
* [FEATURE] Continuous-test: now runable as a module with `mimir -target=continuous-test`. #7747
* [FEATURE] Store-gateway: Allow specific tenants to be enabled or disabled via `-store-gateway.enabled-tenants` or `-store-gateway.disabled-tenants` CLI flags or their corresponding YAML settings. #7653
* [FEATURE] New `-<prefix>.s3.bucket-lookup-type` flag configures lookup style type, used to access bucket in s3 compatible providers. #7684
* [FEATURE] Querier: add experimental streaming PromQL engine, enabled with `-querier.promql-engine=mimir`. #7693 #7898 #7899 #8023 #8058 #8096 #8121 #8197 #8230 #8247 #8270 #8276 #8277 #8291 #8303 #8340
* [FEATURE] Querier: add experimental streaming PromQL engine, enabled with `-querier.promql-engine=mimir`. #7693 #7898 #7899 #8023 #8058 #8096 #8121 #8197 #8230 #8247 #8270 #8276 #8277 #8291 #8303 #8340 #8256
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] Would be good to keep the PRs sorted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Depends if you want them sorted by order merged, or order opened. I'd argue for merged since this branch merges main back into itself and will be squashed and applied on top of what was 8340.

pkg/streamingpromql/functions/math_test.go Outdated Show resolved Hide resolved
pkg/streamingpromql/functions/native_histograms_test.go Outdated Show resolved Hide resolved
pkg/streamingpromql/functions_test.go Show resolved Hide resolved
// Most of the functionality of functions is tested through the test scripts in
// pkg/streamingpromql/testdata.

func TestFunctionOverInstantVector(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't think this is necessary - we can confirm that the functions are called by observing their effects (eg. that the label name has been dropped or that the values returned are equal to acos(<value>)).

pkg/streamingpromql/functions.go Outdated Show resolved Hide resolved
pkg/streamingpromql/functions_test.go Show resolved Hide resolved
pkg/streamingpromql/testdata/ours/functions.test Outdated Show resolved Hide resolved
Copy link
Contributor

@charleskorn charleskorn left a comment

Choose a reason for hiding this comment

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

🚀 LGTM, thanks for this!

CI failures look unrelated to the changes here.

@jhesketh jhesketh merged commit 0c25eb6 into grafana:main Jun 12, 2024
29 checks passed
charleskorn added a commit that referenced this pull request Jun 12, 2024
* Complete renaming from 75506d6

* Add changelog entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants