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

[Discover] Rely on dataSource for ES|QL mode #183108

Merged
merged 14 commits into from
May 18, 2024

Conversation

davismcphee
Copy link
Contributor

@davismcphee davismcphee commented May 10, 2024

Summary

This PR updates Discover to rely on dataSource for determining if ES|QL mode is enabled instead of relying on query directly. This creates a clearer separation between the modes and moves Discover toward supporting multiple data source types. It also includes a number of cleanups around ES|QL mode that make the intent of the code clearer and removes tech debt / code duplication.

Changes included in the PR:

  • Add a new useIsEsqlMode hook that relies on dataSource for checking if Discover is in ES|QL mode.
  • Remove "raw record type" concept in Discover and replace it with ES|QL dataSource checks.
  • Remove references to isPlainRecord and replace them with ES|QL dataSource checks.
  • Remove isTextBasedQuery utility function and replace it with ES|QL dataSource checks or isOfAggregateQueryType where casting is necessary.
  • Replace references to isOfAggregateQueryType with ES|QL dataSource checks except where casting is necessary.
  • Replace other references to "text based" with "ES|QL" for clarity and consistency.

Closes #181963.

Checklist

For maintainers

@davismcphee davismcphee added release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. Project:OneDiscover Enrich Discover with contextual awareness labels May 10, 2024
@davismcphee davismcphee self-assigned this May 10, 2024
@davismcphee
Copy link
Contributor Author

/ci

3 similar comments
@davismcphee
Copy link
Contributor Author

/ci

@davismcphee
Copy link
Contributor Author

/ci

@davismcphee
Copy link
Contributor Author

/ci

@davismcphee davismcphee force-pushed the one-discover-esql-cleanup branch from 034d0a4 to a936f16 Compare May 13, 2024 01:56
@davismcphee
Copy link
Contributor Author

/ci

@davismcphee davismcphee force-pushed the one-discover-esql-cleanup branch from a936f16 to eb3556d Compare May 15, 2024 23:31
@davismcphee
Copy link
Contributor Author

/ci

@davismcphee davismcphee changed the title [Discover] ES|QL cleanup [Discover] Rely on dataSource for ES|QL mode May 15, 2024
@davismcphee davismcphee marked this pull request as ready for review May 16, 2024 01:25
@davismcphee davismcphee requested a review from a team as a code owner May 16, 2024 01:25
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@kertal kertal requested a review from a team May 16, 2024 07:23
Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for the clean up!

I did not see any issues which would be reproducible. At some point I could not switch to Field Statistics tab, another time the histogram was missing - but I can't get to these issues again, maybe something to keep an eye on.

it('should include DocumentViewModeToggle when isPlainRecord is true', async () => {
const component = await mountComponent({ isPlainRecord: true });
it('should include DocumentViewModeToggle when in ES|QL mode', async () => {
const component = await mountComponent();
Copy link
Contributor

Choose a reason for hiding this comment

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

These tests look the same now 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, @davismcphee I think we don't need both

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I updated the test to correctly set this one to ES|QL mode: 42afbd3.

@@ -215,13 +211,13 @@ export const DiscoverTourProvider = ({
);
const tourSteps = useMemo(
() =>
isPlainRecord
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I think we don't need this condition anymore. Looks like ES|QL now also supports all the mentioned functionality.

Copy link
Member

Choose a reason for hiding this comment

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

@davismcphee it so nice to see this go away ... the naming wasn't good anyway, I wonder who ... ah .. it was me :)
I wonder why I didn't I name this isBoringRecord

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 it about? What is the mentioned functionality?

Copy link
Contributor

Choose a reason for hiding this comment

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

@stratoula It's a tour explaining how to use the data grid. For data view mode it has more steps configured.

I can address that separately to show all steps for ES|QL mode too, since we've added more features to it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds fantastic, thanx Julia!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, but yes let's include them in a separate PR to avoid any functionality changes in this one. I opened an issue for it here: #183791.

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

This is a very brave PR 👏 I added some comments / questions but nothing critical. I also did some testing and everything seems to work as expected.

It will cause some conflicts on #180849 and #182557 but I don't think it will be difficult to resolve them.

@@ -416,12 +408,12 @@ function DiscoverDocumentsComponent({
rowHeightState={rowHeight}
onUpdateRowHeight={onUpdateRowHeight}
isSortEnabled={true}
isPlainRecord={isTextBasedQuery}
isPlainRecord={isEsqlMode}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why here we are keeping the isPlainRecord and we dont change the prop to isEsqlMode ? I see that we are doing this in other places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because this component is a trick 😄 It's actually inheriting the props from Unified Data Table, and I wanted to keep this PR limited to the Discover codebase. But it would be a good idea to make similar changes within our shared components too separately.

it('should include DocumentViewModeToggle when isPlainRecord is true', async () => {
const component = await mountComponent({ isPlainRecord: true });
it('should include DocumentViewModeToggle when in ES|QL mode', async () => {
const component = await mountComponent();
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, @davismcphee I think we don't need both

@@ -215,13 +211,13 @@ export const DiscoverTourProvider = ({
);
const tourSteps = useMemo(
() =>
isPlainRecord
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 it about? What is the mentioned functionality?

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
discover 911 910 -1

Async chunks

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

id before after diff
discover 808.8KB 809.4KB +567.0B
unifiedDocViewer 860.0KB 859.9KB -10.0B
total +557.0B

Page load bundle

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

id before after diff
discover 35.6KB 35.6KB -44.0B
unifiedDocViewer 11.5KB 11.4KB -20.0B
total -64.0B
Unknown metric groups

async chunk count

id before after diff
discover 24 23 -1

History

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

cc @davismcphee

Copy link
Contributor Author

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Thanks @jughosta and @stratoula for the feedback! I fixed the Jest test and created a followup issue for the Discover tour. I'm going to merge this PR now since it's a merge conflict magnet 🧲 with all these file changes.

I did not see any issues which would be reproducible. At some point I could not switch to Field Statistics tab, another time the histogram was missing - but I can't get to these issues again, maybe something to keep an eye on.

This is interesting, although I also tried quite a bit to reproduce and was unable to. I agree, let's proceed with this PR since none of us can reproduce it, and keep an eye out for those issues.

it('should include DocumentViewModeToggle when isPlainRecord is true', async () => {
const component = await mountComponent({ isPlainRecord: true });
it('should include DocumentViewModeToggle when in ES|QL mode', async () => {
const component = await mountComponent();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I updated the test to correctly set this one to ES|QL mode: 42afbd3.

@@ -215,13 +211,13 @@ export const DiscoverTourProvider = ({
);
const tourSteps = useMemo(
() =>
isPlainRecord
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, but yes let's include them in a separate PR to avoid any functionality changes in this one. I opened an issue for it here: #183791.

@@ -416,12 +408,12 @@ function DiscoverDocumentsComponent({
rowHeightState={rowHeight}
onUpdateRowHeight={onUpdateRowHeight}
isSortEnabled={true}
isPlainRecord={isTextBasedQuery}
isPlainRecord={isEsqlMode}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because this component is a trick 😄 It's actually inheriting the props from Unified Data Table, and I wanted to keep this PR limited to the Discover codebase. But it would be a good idea to make similar changes within our shared components too separately.

@davismcphee davismcphee merged commit 808a89c into elastic:main May 18, 2024
17 checks passed
@kibanamachine kibanamachine added v8.15.0 backport:skip This commit does not require backporting labels May 18, 2024
@davismcphee davismcphee deleted the one-discover-esql-cleanup branch May 21, 2024 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Project:OneDiscover Enrich Discover with contextual awareness release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Discover] Extend URL state by selected data source
7 participants