-
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
filtering (making it work with expressions) #55351
Conversation
Pinging @elastic/kibana-app-arch (Team:AppArch) |
@@ -292,6 +292,11 @@ export const esaggs = (): ExpressionFunction<typeof name, Context, Arguments, Re | |||
const cleanedColumn: KibanaDatatableColumn = { | |||
id: column.id, | |||
name: column.name, | |||
_meta: { |
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.
any ideas for naming this ?
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.
meta sgtm, but I think I would remove the _
26b2c72
to
4e73315
Compare
975e9d9
to
a67f968
Compare
@@ -292,6 +292,11 @@ export const esaggs = (): ExpressionFunction<typeof name, Context, Arguments, Re | |||
const cleanedColumn: KibanaDatatableColumn = { | |||
id: column.id, | |||
name: column.name, | |||
_meta: { |
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.
meta sgtm, but I think I would remove the _
timeFieldName, | ||
}); | ||
} | ||
const eventName = event.name === 'brush' ? SELECT_RANGE_TRIGGER : APPLY_FILTER_TRIGGER; |
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 am not sure we should separate these out instead of having a single one.
If we think the user will want something different to happen based on which one is emitted, we should separate them, but if in the users head, the same thing should happen, we should leave them together.
Right now, the user see's the same exact thing happen, the only difference here is in the code, to construct a different filter object, but in either case, a filter gets added to the view. But now, if the user wants to add a drilldown, we have two triggers, and we don't really know which one will be emitted from any given visualization. We could try to expose it but that will be difficult with lens when you don't really have the information from the renderer.
One other option is to leave these triggers separately, name them something like you suggested, SELECT_RANGE and CLICKED_DATA_POINT, and actually have each of those actions emit another trigger, maybe named ES_FILTER_SELECTED_TRIGGER. Then drilldowns actions can attach to that trigger name, and it won't matter whether it was a brush or a click, it only matters that the end result was that the user selected some filters, and any relevant drilldowns will apply.
if we wanted to do that, and eventually allow users to attach the raw URL builder drilldown where we will expose the raw data, not the es filter data, we'd need to figure out a way to batch or collect all triggers being emitted in a single event cycle. Otherwise, the user could attach an action on both CLICKED_DATA_POINT, and FILTER_SELECTED, and since they were separately emitted as part of the same event cycle, you'd see two context menu's pop up and we don't want that.
I think probably to avoid complicating drilldown feature, for phase 1, we should have at least one common trigger we can attach the drilldowns to, and not worry about having to figure out whether to attach the drilldown to the select range or data clicked trigger. Then once we expose the ability to attach actions to the triggers that have the raw data, figure out the batching then.
Thoughts?
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 really like your idea about this actions emitting yet another trigger ES_FILTER_SELECTED_TRIGGER
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 will leave creating another trigger ES_FILTER_SELECTED_TRIGGER
out of this PR, but i agree that could be a possible solution to simplify the drilldown (or any user defined action) configuration.
@@ -288,6 +288,11 @@ export const esaggs = (): ExpressionFunction<typeof name, Context, Arguments, Re | |||
const cleanedColumn: KibanaDatatableColumn = { | |||
id: column.id, | |||
name: column.name, | |||
_meta: { | |||
type: column.aggConfig.type, | |||
indexPattern: column.aggConfig.getIndexPattern(), |
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.
Not sure whether that's out of scope for this PR, but the index pattern object is not serializable, right? It's also pretty big: https://github.com/elastic/kibana/pull/55351/files#diff-c85d790e1f9fa1b5d3c3ca92ea62bd60R1
Should this be just the id of the pattern?
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 almost going to add a comment suggesting you name this indexPatternId
to avoid confusion (I thought it was the id).
e317dc5
to
ca586b8
Compare
ca586b8
to
650602c
Compare
0586d2b
to
37a9d0c
Compare
export interface KibanaDatatableColumnMeta { | ||
type: string; | ||
indexPatternId: string; | ||
params: Record<string, any>; |
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.
params: Record<string, any>; | |
aggConfig: Record<string, unknown>; |
Having a generic object called params
is not helpful for our use in client apps- will we need to assume that params
is always the same data?
I suggest renaming to aggConfigs
because that's what it appears to be in this change.
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 aggConfigParams
export interface KibanaDatatableColumn { | ||
id: string; | ||
name: string; | ||
meta?: KibanaDatatableColumnMeta; |
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 not generic metadata about the table column any more- if it were, it would just include type
. The addition of indexPattern
and aggConfigs into the table is not what I would expect for all tables.
Suggestion:
- Move the
type
parameter to the table column - Create a new table type for
KibanaAggregatedTable
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 agree that if we are adding a field for truly generic metadata, it should probably make the agg-specific values in KibanaDatatableColumnMeta
optional, instead of assuming the only use of meta
is ever going to be for aggs. KibanaAggregatedTable
is an interesting idea too.
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 don't know a ton about the vislib legend portion and I'm only somewhat familiar with the syntax for registering custom actions, so can't really comment much on those, but I think the rest makes sense to me in general. Added a few notes.
src/legacy/core_plugins/data/public/search/expressions/utils.ts
Outdated
Show resolved
Hide resolved
src/legacy/core_plugins/data/public/search/expressions/utils.ts
Outdated
Show resolved
Hide resolved
export interface KibanaDatatableColumn { | ||
id: string; | ||
name: string; | ||
meta?: KibanaDatatableColumnMeta; |
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 agree that if we are adding a field for truly generic metadata, it should probably make the agg-specific values in KibanaDatatableColumnMeta
optional, instead of assuming the only use of meta
is ever going to be for aggs. KibanaAggregatedTable
is an interesting idea too.
src/legacy/core_plugins/data/public/actions/value_click_action.ts
Outdated
Show resolved
Hide resolved
# Conflicts: # src/legacy/core_plugins/visualizations/public/embeddable/visualize_embeddable.ts # src/legacy/core_plugins/visualizations/public/np_ready/public/types/base_vis_type.js # src/legacy/ui/public/agg_types/index.ts
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 to reiterate my disclaimer above:
I don't know a ton about the vislib legend portion and I'm only somewhat familiar with the syntax for registering custom actions, so can't really comment much on those
Other than that, code changes here LGTM, pending a green build from CI!
@elasticmachine merge upstream |
@elasticmachine merge upstream |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* adding meta information to KibanaDatatable * updating filtering functions to use new information * moving filter creation to APPLY_FILTER_ACTION * adding SELECT_RANGE_ACTION and TRIGGER * making _meta optional * inlining legacy code for inspector * fixing jest tests * keeping apply_filter_action and adding value_click_action and trigger * utilities for serializing/unserializing aggConfigs * renaming prop to indexPatternId * cleanup * updating interpreter functional baselines * trying to fix tests * Fix legend tests * reverting update to multi metric screenshot * updating based on review * updating tests Co-authored-by: Nick Partridge <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
* adding meta information to KibanaDatatable * updating filtering functions to use new information * moving filter creation to APPLY_FILTER_ACTION * adding SELECT_RANGE_ACTION and TRIGGER * making _meta optional * inlining legacy code for inspector * fixing jest tests * keeping apply_filter_action and adding value_click_action and trigger * utilities for serializing/unserializing aggConfigs * renaming prop to indexPatternId * cleanup * updating interpreter functional baselines * trying to fix tests * Fix legend tests * reverting update to multi metric screenshot * updating based on review * updating tests Co-authored-by: Nick Partridge <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
export const SELECT_RANGE_ACTION = 'SELECT_RANGE_ACTION'; | ||
|
||
interface ActionContext { | ||
data: any; |
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.
Can this be further typed out? The types are so critical to the trigger and what actions can be attached to it.
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'm going to create an issue to track this
let filter = []; | ||
const value = rowIndex > -1 ? table.rows[rowIndex][column.id] : cellValue; | ||
const value = rowIndex > -1 ? table.rows[rowIndex][column.id] : null; |
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.
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.
yes, passing valid rowId is cruical now and regionmap was passing wrong info for a very long time.
Summary
Changes a bit how filtering works so it can work correctly with expressions
partly resolves #46904
esaggs
adds meta information about the agg and field to the KibanaDatatableapply_filter_action
this means that visualization doesn't emit a filter on click, but just information of what was clicked. We use this information in defaultapply_filter_action
to correctly create the filter and apply it. This now makes it way easier to apply other actions, as its easy to extract information like cell value clicked etc.select_range_action
which applies a range filterFOLLOWUP:
esaggs
function. for example you could sum two columns into a new column and visualize it. filtering on that column will not work as meta information required is not provided.in the future we can allow to customize default filter action for this scenarios. user could provide custom expression to build the filter which would be used when meta information provided by
esaggs
is not available.Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.[ ] Documentation was added for features that require explanation or tutorialsFor maintainers
[ ] This was checked for breaking API changes and was labeled appropriately[ ] This includes a feature addition or change that requires a release note and was labeled appropriately