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

[Vis Builder] Add metric to metric, bucket to bucket aggregation persistence #3495

Merged

Conversation

abbyhu2000
Copy link
Member

Description

This PR implements the aggregation persistence feature in Vis Builder when switching vis type.

Detailed research doc can be found here: #2900
The proposal, mapping rules and examples can be found here: #3482

Issues Resolved

#3482

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
    • yarn test:ftr
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

@abbyhu2000 abbyhu2000 self-assigned this Feb 24, 2023
@abbyhu2000 abbyhu2000 force-pushed the aggregation_persistence branch from d239f2d to 2fdfbdf Compare February 28, 2023 23:18
@abbyhu2000 abbyhu2000 marked this pull request as ready for review February 28, 2023 23:20
@abbyhu2000 abbyhu2000 requested a review from a team as a code owner February 28, 2023 23:20
@codecov-commenter
Copy link

codecov-commenter commented Mar 1, 2023

Codecov Report

Merging #3495 (42a7684) into main (69bcbfe) will decrease coverage by 0.01%.
The diff coverage is 70.58%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main    #3495      +/-   ##
==========================================
- Coverage   66.45%   66.45%   -0.01%     
==========================================
  Files        3205     3206       +1     
  Lines       61562    61596      +34     
  Branches     9497     9503       +6     
==========================================
+ Hits        40914    40936      +22     
- Misses      18377    18387      +10     
- Partials     2271     2273       +2     
Flag Coverage Δ
Linux 66.40% <70.58%> (-0.01%) ⬇️
Windows 66.40% <70.58%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...uilder/public/application/components/right_nav.tsx 11.11% <0.00%> (-2.23%) ⬇️
...plication/utils/state_management/shared_actions.ts 100.00% <ø> (ø)
...tion/utils/state_management/visualization_slice.ts 33.33% <ø> (ø)
.../application/utils/use/use_persisted_agg_params.ts 77.41% <77.41%> (ø)
...s/osd-optimizer/src/node/node_auto_tranpilation.ts 83.67% <0.00%> (-4.09%) ⬇️
packages/osd-optimizer/src/node/cache.ts 51.31% <0.00%> (-2.64%) ⬇️
...ared/static/forms/hook_form_lib/hooks/use_field.ts 66.66% <0.00%> (+0.96%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

Love how surgical and clean the implementation is.

Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

These tests are in the right direction but not exactly what i was looking for. The reason i wanted the unit tests was to ensure that the logic you described in the parent issue works as expected, and if that changes, these tests should catch it. I dont see a test here that validates that logic. There are just 3 tests here that i am really looking for:

  1. A test for usePersistedAggParams that given a list of appParams, an old and new vis type can successfully map the params to the new type.
  2. A test to show how the hook would drop values if it did not find a way to map the params successfully. e.g. goes over the max count
  3. Any edge cases that we need to cover. e.g. no schema

The rest of the functions dont really need tests since they are helper functions that help the hook function as expected.

@abbyhu2000 abbyhu2000 force-pushed the aggregation_persistence branch from 42a7684 to 1d32f58 Compare March 8, 2023 21:05
@abbyhu2000
Copy link
Member Author

These tests are in the right direction but not exactly what i was looking for. The reason i wanted the unit tests was to ensure that the logic you described in the parent issue works as expected, and if that changes, these tests should catch it. I dont see a test here that validates that logic. There are just 3 tests here that i am really looking for:

  1. A test for usePersistedAggParams that given a list of appParams, an old and new vis type can successfully map the params to the new type.
  2. A test to show how the hook would drop values if it did not find a way to map the params successfully. e.g. goes over the max count
  3. Any edge cases that we need to cover. e.g. no schema

The rest of the functions dont really need tests since they are helper functions that help the hook function as expected.

@ashwin-pc Rewrote the unit test to test the parent function as a whole under different scenarios.

Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

Love the new tests and the feature!

};
});

test('return the correct metric-to-metric, bucket-to-bucket mapping and correct persisted aggregations', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Nice test!

`);
});

test('aggregations with undefined schema remain undefined; schema will be set to undefined if aggregations that exceeds the max amount', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Nice combining two tests in one

@abbyhu2000 abbyhu2000 merged commit 525b033 into opensearch-project:main Mar 10, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Mar 10, 2023
…istence (#3495)

* Add metric to metric, bucket to bucket aggregation persistance

Signed-off-by: abbyhu2000 <[email protected]>

* Add logics to avoid exceeding the max count for each schema field

Signed-off-by: abbyhu2000 <[email protected]>

* Add changelog entry

Signed-off-by: abbyhu2000 <[email protected]>

* addressing comments

Signed-off-by: abbyhu2000 <[email protected]>

* Add unit tests for functions in use_persisted_agg_params

Signed-off-by: abbyhu2000 <[email protected]>

* rewrite unit tests to test the entire functionality

Signed-off-by: abbyhu2000 <[email protected]>

---------

Signed-off-by: abbyhu2000 <[email protected]>
Co-authored-by: Anan Zhuang <[email protected]>
(cherry picked from commit 525b033)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
sikhote pushed a commit to sikhote/OpenSearch-Dashboards that referenced this pull request Apr 24, 2023
…istence (opensearch-project#3495)

* Add metric to metric, bucket to bucket aggregation persistance

Signed-off-by: abbyhu2000 <[email protected]>

* Add logics to avoid exceeding the max count for each schema field

Signed-off-by: abbyhu2000 <[email protected]>

* Add changelog entry

Signed-off-by: abbyhu2000 <[email protected]>

* addressing comments

Signed-off-by: abbyhu2000 <[email protected]>

* Add unit tests for functions in use_persisted_agg_params

Signed-off-by: abbyhu2000 <[email protected]>

* rewrite unit tests to test the entire functionality

Signed-off-by: abbyhu2000 <[email protected]>

---------

Signed-off-by: abbyhu2000 <[email protected]>
Co-authored-by: Anan Zhuang <[email protected]>
Signed-off-by: David Sinclair <[email protected]>
sikhote pushed a commit to sikhote/OpenSearch-Dashboards that referenced this pull request Apr 24, 2023
…istence (opensearch-project#3495)

* Add metric to metric, bucket to bucket aggregation persistance

Signed-off-by: abbyhu2000 <[email protected]>

* Add logics to avoid exceeding the max count for each schema field

Signed-off-by: abbyhu2000 <[email protected]>

* Add changelog entry

Signed-off-by: abbyhu2000 <[email protected]>

* addressing comments

Signed-off-by: abbyhu2000 <[email protected]>

* Add unit tests for functions in use_persisted_agg_params

Signed-off-by: abbyhu2000 <[email protected]>

* rewrite unit tests to test the entire functionality

Signed-off-by: abbyhu2000 <[email protected]>

---------

Signed-off-by: abbyhu2000 <[email protected]>
Co-authored-by: Anan Zhuang <[email protected]>
Signed-off-by: David Sinclair <[email protected]>
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.

5 participants