-
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
[visualizations] Rewrite expression pipeline builder to use AST builder #65396
Conversation
…xpressions plugin.
return expr; | ||
const visConfig = buildVisConfig.tagcloud(schemas); | ||
|
||
const visdimensionMetric = visConfig.metric |
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.
metric needs to be preent for tagcloud, so i don't think we need to check for it
} | ||
}; | ||
|
||
export const prepareDimension = (variable: string, 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.
i think this utility function is still useful to prevent code duplication across all vis types
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.
lets just update it to return expression function or undefined
}) | ||
: undefined; | ||
|
||
const visdimensionBucketFn = |
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.
a lot of code duplication, the function we had makes sense still
} | ||
|
||
if (savedSearchId) { | ||
kibanaContext.addArgument('savedSearchId', savedSearchId); |
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.
kibanaContext is not added to pipeline
}) | ||
); | ||
} else if (vis.type.toExpression) { | ||
pipeline.functions.push(await vis.type.toExpression(vis, params)); |
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 might want to return expression from toExpression, so chart can optionally return more than one function, so we should concat the chains
pipeline.functions.push(buildExpressionFunction(fnName, args)) | ||
); | ||
} else if (vislibCharts.includes(vis.type.name)) { | ||
const visConfig = { ...vis.params }; |
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 needs to be moved to vislib charts toExpression function
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 be done in followup, but lets open an issue for it)
@@ -258,49 +227,49 @@ const adjustVislibDimensionFormmaters = (vis: Vis, dimensions: { y: any[] }): vo | |||
}; | |||
|
|||
export const buildPipelineVisFunction: BuildPipelineVisFunction = { | |||
vega: params => { | |||
return `vega ${prepareString('spec', params.spec)}`; | |||
vega: ({ spec }) => { |
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.
all of these should move to specific charts toExpression function, can be done in followup
|
||
// request handler | ||
if (vis.type.requestHandler === 'courier' && indexPattern?.id) { | ||
pipeline.functions.push( |
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 a note .... once esaggs function is refactored we'll be able to do pipeline.functions.push(vis.data.aggs.toExpressionAST())
} else if (vis.type.toExpression) { | ||
pipeline.functions.push(await vis.type.toExpression(vis, params)); | ||
} else { | ||
const visConfig = { ...vis.params }; |
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 case should be removed, same can be achieved by visualizations implementing toExpression function
Closing as this is very outdated. As noted in #51246, the app team will revisit whether this effort is even necessary after they have implemented renderers for each vis type. |
WIP
Closes #51246, #61829
Remaining tasks:
buildPipeline
& corresponding dependenciesbuildPipelineVisFunction
buildVisConfig
toExpressionAst
to vis object