-
Notifications
You must be signed in to change notification settings - Fork 11.6k
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
Transformations: Cumulative and window modes for Add field from calculation
#77029
Conversation
* Add window function, rename statistical to cumulative * Fix merge errors * fix more merge errors
Co-authored-by: Oscar Kilhed <oscar.kilhed@grafana.com>
Co-authored-by: Oscar Kilhed <oscar.kilhed@grafana.com>
packages/grafana-data/src/transformations/transformers/calculateField.ts
Outdated
Show resolved
Hide resolved
* make sum and mean cumulative more efficient * remove cumulative variance, add window stddev * refactor window to not use reducer for mean. wip variance stdDev * fix tests after optimization --------- Co-authored-by: Victor Marin <victor.marin@grafana.com>
Add field from calculation
* make sum and mean cumulative more efficient * remove cumulative variance, add window stddev * refactor window to not use reducer for mean. wip variance stdDev * fix tests after optimization * fix test lint * optimize window * tests are passing * fix nulls * fix all nulls --------- Co-authored-by: Victor Marin <victor.marin@grafana.com>
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.
Looks like the percentage thing broke the tests
docs/sources/panels-visualizations/query-transform-data/transform-data/index.md
Show resolved
Hide resolved
packages/grafana-data/src/transformations/transformers/calculateField.ts
Show resolved
Hide resolved
packages/grafana-data/src/transformations/transformers/calculateField.ts
Outdated
Show resolved
Hide resolved
packages/grafana-data/src/transformations/transformers/calculateField.ts
Outdated
Show resolved
Hide resolved
packages/grafana-data/src/transformations/transformers/calculateField.ts
Outdated
Show resolved
Hide resolved
public/app/features/transformers/editors/CalculateFieldTransformerEditor.tsx
Outdated
Show resolved
Hide resolved
I'm wondering if there is anything special we need to do with the docs since we have the new modes behind a feature flag? |
I'm happy to set up some sort of conditional |
I think just a text in content should be enough. Will modify |
@imatwawana can I please ask for your feedback on the note I added for each of the new modes (window/cumulative) saying that it's behind a feature toggle? Would this be ok? |
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.
Have a couple comments but honestly feels a bit like nitpicking. Tested things out and appears to be functioning great. This is awesome!
Only comment I have beyond that is that it would be nice to see some more TSDoc comments. Overall though it's pretty readable 😄
@@ -46,6 +69,13 @@ const defaultReduceOptions: ReduceOptions = { | |||
reducer: ReducerID.sum, | |||
}; | |||
|
|||
export const defaultWindowOptions: WindowOptions = { |
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.
Since this is a constant feels like it should be DEFAULT_WINDOW_OPTIONS
.
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.
This is a nit, but could be confusing as window is usually used to refer to interface windows.
**Note:** This mode is an experimental feature. Engineering and on-call support is not available. | ||
Documentation is either limited or not provided outside of code comments. No SLA is provided. | ||
Enable the 'addFieldFromCalculationStatFunctions' in Grafana to use this feature. | ||
Contact Grafana Support to enable this feature in Grafana Cloud. |
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.
**Note:** This mode is an experimental feature. Engineering and on-call support is not available. | |
Documentation is either limited or not provided outside of code comments. No SLA is provided. | |
Enable the 'addFieldFromCalculationStatFunctions' in Grafana to use this feature. | |
Contact Grafana Support to enable this feature in Grafana Cloud. | |
{{% admonition type="note" %}} | |
This mode is an experimental feature. Engineering and on-call support is not available. Documentation is either limited or not provided outside of code comments. No SLA is provided. Enable the 'addFieldFromCalculationStatFunctions' in Grafana to use this feature. Contact Grafana Support to enable this feature in Grafana Cloud. | |
{{% /admonition %}} |
…ulation` (#77029) * cumulative sum * refactor and create new mode * refactor - use reduceOptions for new mode also * revert naming * Add window function, rename statistical to cumulative (#77066) * Add window function, rename statistical to cumulative * Fix merge errors * fix more merge errors * refactor + add window funcs Co-authored-by: Oscar Kilhed <oscar.kilhed@grafana.com> * add ff + tests + centered moving avg Co-authored-by: Oscar Kilhed <oscar.kilhed@grafana.com> * make sum and mean cumulative more efficient (#77173) * make sum and mean cumulative more efficient * remove cumulative variance, add window stddev * refactor window to not use reducer for mean. wip variance stdDev * fix tests after optimization --------- Co-authored-by: Victor Marin <victor.marin@grafana.com> * optimize window func (#77266) * make sum and mean cumulative more efficient * remove cumulative variance, add window stddev * refactor window to not use reducer for mean. wip variance stdDev * fix tests after optimization * fix test lint * optimize window * tests are passing * fix nulls * fix all nulls --------- Co-authored-by: Victor Marin <victor.marin@grafana.com> * change window size to be percentage * fix tests to use percentage * fixed/percentage window size (#77369) * Add docs for cumulative and window functions of the add field from calculation transform. (#77352) add docs * splling * change WindowType -> WindowAlignment * update betterer * refactor getWindowCreator * add docs to content.ts * add feature toggle message --------- Co-authored-by: Oscar Kilhed <oscar.kilhed@grafana.com>
What is this feature?
Adds a cumulative and window functions
to add field from calc
Why do we need this feature?
Provide a way to get cumulative total/mean, moving average/stddev/variance for data sources where the query model does not support it.
Who is this feature for?
All users
Which issue(s) does this PR fix?:
Fixes #74480
Special notes for your reviewer:
The transformation is getting rather big so we will need to refactor it in the future and break it up a bit. Issue for tracking here.
Please check that: