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

[Canvas] Use dataviews api in canvas #130320

Closed
wants to merge 2 commits into from

Conversation

crob611
Copy link
Contributor

@crob611 crob611 commented Apr 14, 2022

Part of #91715

This PR is pretty straightforward. Creates a DataViews service to replace the existing es_services file and updates all of the locations that use those services.

@crob611 crob611 added review Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas loe:medium Medium Level of Effort release_note:skip Skip the PR/issue when compiling release notes Feature:Canvas v8.3.0 labels Apr 14, 2022
@crob611 crob611 requested a review from a team as a code owner April 14, 2022 20:07
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@crob611 crob611 changed the title Use dataviews api in canvas [Canvas] Use dataviews api in canvas Apr 14, 2022
@crob611 crob611 added the impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. label Apr 14, 2022
@crob611 crob611 force-pushed the canvas-data-views branch from 894d614 to 26bc6b9 Compare April 15, 2022 14:09
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
canvas 1.0MB 1.0MB -1.3KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
canvas 13.3KB 13.3KB -8.0B

History

  • 💔 Build #38337 failed 894d6147ed709a3f1faef1f9f1c7632acfb1c5d3

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@crob611 crob611 requested a review from mattkime April 15, 2022 18:58
loading: boolean;
value: string;
indices: string[];
onChange: (index: string) => void;
dataViews: string[];
Copy link
Contributor

Choose a reason for hiding this comment

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

How are dataViews represented by strings? Just making sure will work in all circumstances.

getDataViews: async () => {
try {
const dataViews = await startPlugins.data.dataViews.getIdsWithTitle();
return dataViews.map((view) => view.title);
Copy link
Contributor

Choose a reason for hiding this comment

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

This code appears to assume that titles are unique. Only ids should be considered unique.


return [];
},
getFields: async (dataViewTitle: string) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this used exclusively when an existing data view doesn't exist? Why are all fields starting with _ being filtered out? It is valid to have an indexed field that starts with _.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is used when we have a title, and need to get the fields. The _ fields are filtered out as an attempt to remove meta fields it appears. Is there something formalized with the DataView api's to filter out meta fields? Is the create the correct route to go when we have only the title and need to fields?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the user thinking in terms of data views or index pattern strings? If they're using data views then you should get the field list from the data view directly. Lets establish this and then discuss handling meta fields.

.map((field) => field.name);
},
getDefaultDataView: async () => {
const dataView = await startPlugins.data.dataViews.getDefaultDataView();
Copy link
Contributor

Choose a reason for hiding this comment

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

title should not be assumed to be unique.

Copy link
Contributor

@mattkime mattkime left a comment

Choose a reason for hiding this comment

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

Mostly concerned with apparently referencing data views by title rather than id. At very least worth discussing.

@crob611
Copy link
Contributor Author

crob611 commented May 2, 2022

@mattkime Great points you bring up. Let me address here, and then maybe we sync up to come with a better plan moving forward. I hope that this PR simply ports the existing code to use the new data views api, but maybe we can fix some of the issues that this area has had from the beginning.

The DataViewSelect component (previously EsIndexSelect) is used to select a DataView, and the title is passed out on change. In Canvas, this title is used to populate an argument of an expression language expression. So, it looks something like
image

And selecting one will update the expression with that DataView's title
image

That string value of "index" is then used as an index argument on a query to a data.search call, so it's not actually being used as a DataView, just using the title as the index argument.

Maybe this is something that doesn't need to use DataViews in that case, since we are using it as a straight up index pattern instead? Previously we were querying for index-pattern saved objects (https://github.com/elastic/kibana/blob/main/x-pack/plugins/canvas/public/lib/es_service.ts#L50) and using those titles, so, same functionality we'd see here I think.

Anyways, like I said, interested to hear your thoughts and we can sync up if we want to discuss further.

@mattkime
Copy link
Contributor

mattkime commented May 2, 2022

@crob611 I think that makes sense since the title is being consumed in a particular way.


I'm a little confused as to why Index is the name of the dropdown field and its apparently showing data view titles. It seems like it says 'select an index' and its offering data views.

@cqliu1 cqliu1 mentioned this pull request Aug 29, 2022
9 tasks
@cqliu1
Copy link
Contributor

cqliu1 commented Aug 29, 2022

Closing in favor of #139610.

@cqliu1 cqliu1 closed this Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Canvas impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:medium Medium Level of Effort release_note:skip Skip the PR/issue when compiling release notes review Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants