-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[ES|QL] Add ECS information to the editor hint & prioritize fields based on ECS information on the editor #187922
Conversation
/ci |
/ci |
/ci |
/ci |
Pinging @elastic/kibana-esql (Team:ESQL) |
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 awesome 😍 I love it, can you take a look on my comment below? We might not be able to improve it but if you can confirm for me would be awesome!
Not sure if it is possible with Monaco:
Here if I dont open the popover it feels a bit weird that looks like String ECS...
, I would expect at least a separator.
In cases without the description I like the fact that I see the type here
but opening the popover to see the type again is unnecessary.
I wonder if we can do something better here. Possibly not because monaco doesnt allow us but can you take a look just to confirm?
import type { FieldsMetadataPublicStart } from '@kbn/fields-metadata-plugin/public'; | ||
|
||
describe('getColumnsWithMetadata', () => { | ||
it('should return columns as is if fieldsMetadata is not provided', async () => { |
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.
it('should return columns as is if fieldsMetadata is not provided', async () => { | |
it('should return columns if fieldsMetadata is not provided', async () => { |
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.
Updated here 22db292
(#187922)
expect(result).toEqual(columns); | ||
}); | ||
|
||
it('should return columns as is if ECS version field is not present', async () => { |
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.
it('should return columns as is if ECS version field is not present', async () => { | |
it('should return columns if ECS version field is not present', async () => { |
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.
Updated here 22db292
(#187922)
@@ -18,6 +18,9 @@ export interface ESQLVariable { | |||
export interface ESQLRealField { |
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 name is funny 😄
@@ -430,7 +440,8 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({ | |||
undefined, | |||
abortController | |||
).result; | |||
return table?.columns.map((c) => ({ name: c.name, type: c.meta.type })) || []; | |||
const columns = table?.columns.map((c) => ({ name: c.name, type: c.meta.type })) || []; | |||
return await getColumnsWithMetadata(columns, fieldsMetadata); |
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.
Very smart you are doing this here, this way we are using the cache 👏
const fields = await fieldsMetadataClient.find({ | ||
fieldNames: columns.map((c) => c.name), | ||
}); | ||
|
||
if (fields.fields) { | ||
return columns.map((c) => ({ | ||
...c, | ||
// Metadata services gives description for | ||
// 'ecs.version' but not 'ecs.version.keyword' | ||
// but both should show description if available | ||
metadata: fields.fields[removeKeywordSuffix(c.name)], | ||
})); | ||
} |
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.
Great usage of the FieldsMetadata service @qn895 👏
Tip
A further optimization here is to reduce a lot the API response payload by only keeping the field attributes you need, which I think it only consists of description
so far! You can achieve it by passing the attributes
option, this will return only the essential attributes for this use case and reduce quite a lot the API response size:
const {fields} = await fieldsMetadataClient.find({
fieldNames: columns.map((c) => c.name),
attributes: ['description']
});
if (fields) {
return columns.map((c) => ({
...c,
// Metadata services gives description for
// 'ecs.version' but not 'ecs.version.keyword'
// but both should show description if available
metadata: fields[removeKeywordSuffix(c.name)],
}));
}
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.
Updated here 2695236
const metadata = fields.fields[removeKeywordSuffix(c.name)]; | ||
|
||
// Need to convert metadata's type (e.g. keyword) to ES|QL type (e.g. string) to check if they are the same | ||
if (!metadata || convertEcsFieldTypeToESQLType(metadata.type) !== c.type) return c; |
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.
We could also use esFieldTypeToKibanaFieldType(metadata.type) !== c.type
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.
Perfection! Thanks for the hint. Updated here 567cfa9
(#187922)
/ci |
@@ -60,4 +60,4 @@ | |||
.TextBasedLangEditor--expanded .monaco-editor, .TextBasedLangEditor--expanded .monaco-editor .margin, .TextBasedLangEditor--expanded .monaco-editor .overflow-guard { | |||
border-top-left-radius: 0; | |||
border-bottom-left-radius: 0; | |||
} |
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.
If you revert this exactly as it was, we won't need the design team review
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 awesome! LGTM! 👏
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 great! Other feedback thus far seems to have tightened the UX up even further.
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
cc @qn895 |
Summary
Closes #181036. This PR adds ECS information to the editor hint & prioritizes fields based on ECS information on the editor. The logic involves:
Screen.Recording.2024-07-11.at.12.27.00.mov
Note for reviewers:
Checklist
Delete any items that are not applicable to this PR.
Risk Matrix
Delete this section if it is not applicable to this PR.
Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.
When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:
For maintainers