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

Indexed views framework #8851

Merged
merged 12 commits into from
Nov 14, 2024

Conversation

amsiglan
Copy link
Collaborator

Description

In this PR we add support for

  1. Selecting indexed view inside dataset selector. The indexed view is an Opensearch index which can be created for an external source like S3. When user selects an indexed view, we use this index for querying the data
  2. Showing a banner at the top of Discover results canvas. This banner can be used to show actions related to the selected dataset. The first use we will add for this banner would be to show a callout to create an indexed view while searching an external source, or when an indexed view is selected, we can show an entry point to select other indexed view

Issues Resolved

New feature

Screenshot

Note: Below screenshots were produced by making changes to the S3 type config for testing and are not part of this PR since this PR is only adding the framework.

  • Callout for creating indexed view
image
  • Action from callout can open the create flyout (this is all handled by the type config provider and not in this PR's code)
image
  • Create indexed view banner:
image

Testing the changes

Set up workspace with query enhancements enabled

  • For the banner in Discover canvas
  1. [For testing only]: Update the S3 config type to return the banner props based on the fetch status
  2. Discover will render the banner based on provided props
  • For showing indexed views in dataset selector
  1. Update the S3 config type to return implemented instance of IndexedViewsService
  2. Dataset selector will show the indexed views in the second step

Changelog

  • feat: Add framework to show banner at the top in discover results canvas
  • feat: Show indexed views in dataset selector

Check List

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

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.39%. Comparing base (25d3de7) to head (d9bbd23).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8851      +/-   ##
==========================================
- Coverage   60.90%   56.39%   -4.52%     
==========================================
  Files        3800     1239    -2561     
  Lines       90845    25913   -64932     
  Branches    14316     4437    -9879     
==========================================
- Hits        55331    14613   -40718     
+ Misses      31994    10559   -21435     
+ Partials     3520      741    -2779     
Flag Coverage Δ
Linux_1 ?
Linux_2 56.39% <ø> (ø)
Linux_3 ?
Linux_4 ?
Windows_1 ?
Windows_2 ?
Windows_3 ?
Windows_4 ?

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@virajsanghvi virajsanghvi left a comment

Choose a reason for hiding this comment

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

Callout that there are multiple ci items failing - please take a look (looks like lint and snapshot tests, and patch coverage). Also, given patch coverage % and the fact that this is a framework for adding additional functionality, would expect unit test coverage to be higher.

Copy link
Collaborator

@virajsanghvi virajsanghvi left a comment

Choose a reason for hiding this comment

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

Does this incorporate all feedback addressed in #8818?

Can you point out the major new changes from previous PRs?

/** Optional reference to the source dataset. Example usage is for indexed views to store the
* reference to the table dataset
*/
ref?: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we name this something less generic?

@kavilla Is this the right place for this? Isn't the source an attribute of the index that was created? Would expect that to be part of DataSource definition I guess, although if this is a two-way door seems fine for now (I think it would be as not having source in the right place wouldn't impact functionality for saved query/recent dataset?).

Copy link
Member

Choose a reason for hiding this comment

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

that is a good point. for example we do store the session id wtih the meta info about the data source since it's the data source that decides that where as the data source would also include the index that is pointing to. originally i think we though it should go in the data source meta but didn't have too much of hard buy in on the data source. but reflecting it makes more sense there.

agreeed as well this is a two way door. as i believe we can still be able to query the info i think the ref now is used for ui purposes (for now) but def will need to update it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we create an issue to track the rename and move?

}
)}
</EuiFormLabel> }
onChange={(e) => setSelectIndexedView(e.target.checked)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Didn't @riysaxen-amzn add tests for a bunch of these? Looks like they're all here, but not sure why coverage report looks different

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.

Didnt get a chance to review the configurator changes but had a look at the rest. Added my comments below. I agree with Viraj, can we add unit tests for the new code introduced?

Signed-off-by: Amardeepsingh Siglani <[email protected]>
Signed-off-by: Amardeepsingh Siglani <[email protected]>
Signed-off-by: Amardeepsingh Siglani <[email protected]>
Signed-off-by: Amardeepsingh Siglani <[email protected]>
Signed-off-by: Amardeepsingh Siglani <[email protected]>
/** Optional reference to the source dataset. Example usage is for indexed views to store the
* reference to the table dataset
*/
sourceDatasetRef?: {
Copy link
Member

Choose a reason for hiding this comment

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

nit:
where you able to comment on @virajsanghvi previous feedback?
def could be follow up but just some insight url length is limited:

  • Application and global state are stored in URL parameters
  • Although we're far from URL length limits, field name length matters
  • Should follow existing naming conventions (e.g. 'timeFieldName' from index patterns)
  • Consider shorter property names when possible

Copy link
Collaborator

@virajsanghvi virajsanghvi Nov 13, 2024

Choose a reason for hiding this comment

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

I suggested this name - ideally we aren't coupling our interfaces to urls so they aren't impacted by url limits.

Do you have a suggested name that accurately reflects what this is?

Copy link
Member

Choose a reason for hiding this comment

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

Do you have a suggested name that accurately reflects what this is?

nope :). i didn't have a good suggestion and was being pedantic and something to keep track of.

Copy link
Collaborator

@virajsanghvi virajsanghvi left a comment

Choose a reason for hiding this comment

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

Can we resolve @kavilla's concern around the connected data source?

src/plugins/data/public/ui/query_editor/_query_editor.scss Outdated Show resolved Hide resolved
/** Optional reference to the source dataset. Example usage is for indexed views to store the
* reference to the table dataset
*/
sourceDatasetRef?: {
Copy link
Collaborator

@virajsanghvi virajsanghvi Nov 13, 2024

Choose a reason for hiding this comment

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

I suggested this name - ideally we aren't coupling our interfaces to urls so they aren't impacted by url limits.

Do you have a suggested name that accurately reflects what this is?

Signed-off-by: Amardeepsingh Siglani <[email protected]>
@@ -141,7 +141,7 @@
}

.osdQueryEditor__bottomPanel {
margin: 5px 0;
margin: $euiSizeXS 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a call out - this isn't equivalent to 5px

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed it from here and yes 4px would also be fine in this case

Signed-off-by: Amardeepsingh Siglani <[email protected]>
Signed-off-by: Amardeepsingh Siglani <[email protected]>
return dataset;
}

let connectedDataSource;
Copy link
Member

Choose a reason for hiding this comment

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

can be a fast follow but i think the indexed view service could handle fetching the datasource and creating and returning an indexed view vs the configurator doing this work

kavilla
kavilla previously approved these changes Nov 14, 2024
/**
* Currently set Query
*/
query: Query;
Copy link
Member

Choose a reason for hiding this comment

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

nit: what are we using this for? if it's for accessing the current query since it's with the same component it should already have access to the same query. therefore we could just access this query directly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is used to access the dataset on the query, passed in query to be future safe

virajsanghvi
virajsanghvi previously approved these changes Nov 14, 2024
Copy link
Collaborator

@virajsanghvi virajsanghvi left a comment

Choose a reason for hiding this comment

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

Approving assuming ci passes

Signed-off-by: Amardeepsingh Siglani <[email protected]>
@amsiglan amsiglan dismissed stale reviews from virajsanghvi and kavilla via 1057f9e November 14, 2024 02:53
Copy link
Collaborator

@virajsanghvi virajsanghvi left a comment

Choose a reason for hiding this comment

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

Restarted failing ci, did pass on linux so assuming it'll pass on windows

@ashwin-pc
Copy link
Member

Skipping CI group 10 since the failed test case seems to be flakey. The rest of the tests in the suite pass

queries.spec.js.mp4

@ashwin-pc ashwin-pc merged commit 413697d into opensearch-project:main Nov 14, 2024
66 of 67 checks passed
amsiglan added a commit to amsiglan/OpenSearch-Dashboards that referenced this pull request Nov 20, 2024
* indexed-view-working

Signed-off-by: Amardeepsingh Siglani <[email protected]>

* working skeleton

Signed-off-by: Amardeepsingh Siglani <[email protected]>

* Changeset file for PR opensearch-project#8851 created/updated

* removed unwanted changes

Signed-off-by: Amardeepsingh Siglani <[email protected]>

* fixed linter errors; failing UT

Signed-off-by: Amardeepsingh Siglani <[email protected]>

* added some UTs

Signed-off-by: Amardeepsingh Siglani <[email protected]>

* added more UTs

Signed-off-by: Amardeepsingh Siglani <[email protected]>

* refactored code to address comments

Signed-off-by: Amardeepsingh Siglani <[email protected]>

* minor updates

Signed-off-by: Amardeepsingh Siglani <[email protected]>

* minor updates

Signed-off-by: Amardeepsingh Siglani <[email protected]>

* updated tests

Signed-off-by: Amardeepsingh Siglani <[email protected]>

* fixed UT

Signed-off-by: Amardeepsingh Siglani <[email protected]>

---------

Signed-off-by: Amardeepsingh Siglani <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
@amsiglan amsiglan mentioned this pull request Nov 20, 2024
7 tasks
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.

6 participants