-
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
[data views] DataViewLazy implementation phase 1 #173948
[data views] DataViewLazy implementation phase 1 #173948
Conversation
…nto data_view_async_fields
…c_fields_new_class
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 job, Matt!
src/plugins/data_views/common/data_views/abstract_data_views.ts
Outdated
Show resolved
Hide resolved
src/plugins/data_views/server/rest_api_routes/public/create_data_view.ts
Outdated
Show resolved
Hide resolved
src/plugins/data_views/server/rest_api_routes/public/scripted_fields/update_scripted_field.ts
Show resolved
Hide resolved
...lugins/observability_solution/logs_shared/server/services/log_views/log_views_client.test.ts
Outdated
Show resolved
Hide resolved
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.
LGTM 👍
Relying on tests here.
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.
I haven't made it all the way through yet and will finish up my review tomorrow, but it's looking good overall! Just a few comments so far.
src/plugins/data_views/server/rest_api_routes/public/create_data_view.ts
Outdated
Show resolved
Hide resolved
src/plugins/data_views/server/rest_api_routes/public/runtime_fields/create_runtime_field.ts
Outdated
Show resolved
Hide resolved
src/plugins/data_views/server/rest_api_routes/public/runtime_fields/get_runtime_field.ts
Outdated
Show resolved
Hide resolved
Sorry, merge conflicts are because of #178983 I introduced a new param to |
…me/kibana into data_views_async_fields_new_class
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.
I made it through the rest of the code, and it's looking good overall! Left some feedback, mostly questions and a few minor suggestions.
@@ -1078,11 +1206,11 @@ export class DataViewsService { | |||
overwrite, | |||
})) as SavedObject<DataViewAttributes>; | |||
|
|||
const createdIndexPattern = await this.initFromSavedObject(response, displayErrors); |
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.
Just curious why we no longer need to call this anymore?
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 were recreating the dataview on save. instead, we're modifying the one we've been handed.
if (cachedField) { | ||
cachedField.runtimeField = field.runtimeField; | ||
cachedField.spec.type = castEsToKbnFieldTypeName(field.type); | ||
cachedField.spec.esTypes = [field.type]; | ||
} else { |
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.
Just curious, why do we update cachedField
from the spec when we get runtime fields?
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.
I think you're right, this is unneeded.
} | ||
); | ||
|
||
return [field]; |
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.
Why do we return an array from this method?
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.
Its consistent with adding a composite runtime field which can return more than one field.
if (fld) { | ||
this.fieldCache.delete(field.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.
Also curious why we delete and re-add scripted fields to the cache when we get them?
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.
Scripted fields override mapped fields. Added a comment to the code.
return field ? field.type === 'date_nanos' : false; | ||
} | ||
|
||
getTimeField = () => (this.timeFieldName ? this.getFieldByName(this.timeFieldName) : undefined); |
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.
getTimeField = () => (this.timeFieldName ? this.getFieldByName(this.timeFieldName) : undefined); | |
getTimeField = async () => (this.timeFieldName ? this.getFieldByName(this.timeFieldName) : undefined); |
It might be worth making this method async to return Promise<DataViewField | undefined>
instead of Promise<DataViewField> | undefined
which seems trickier for consumers.
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.
They're equivalent constructs. Awaiting non promises simply returns the item being awaited.
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.
I was thinking more if a consumer is using promises since they'd have to conditionally call .then()
, but it's a minor nit and also not breaking if we decided to change it later, so I think it's fine to leave as is.
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.
Ah, good point
src/plugins/data_views/server/rest_api_routes/public/runtime_fields/get_runtime_field.ts
Outdated
Show resolved
Hide resolved
…me/kibana into data_views_async_fields_new_class
/ci |
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
References to deprecated APIs
History
To update your PR or re-run it, just comment with: cc @mattkime |
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.
The latest changes LGTM, I think this is ready to go 👍 Great work, and I'm excited to see this merged so we can start using it!
return field ? field.type === 'date_nanos' : false; | ||
} | ||
|
||
getTimeField = () => (this.timeFieldName ? this.getFieldByName(this.timeFieldName) : undefined); |
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.
I was thinking more if a consumer is using promises since they'd have to conditionally call .then()
, but it's a minor nit and also not breaking if we decided to change it later, so I think it's fine to leave as is.
Summary
Part 1 of #178594
Initial implementation of DataViewLazy class - an alternative DataView implementation that doesn't load the full field list on initial creation.
Closes #176426 and #167750