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

[visualizations] Rewrite expression pipeline builder to use AST builder #65396

Closed
wants to merge 17 commits into from

Conversation

lukeelmers
Copy link
Member

@lukeelmers lukeelmers commented May 5, 2020

WIP

Closes #51246, #61829

Remaining tasks:

  • Remove old buildPipeline & corresponding dependencies
  • Remove buildPipelineVisFunction
  • Remove or refactor buildVisConfig
  • Add toExpressionAst to vis object
  • Add more tests

@botelastic botelastic bot added the Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) label May 5, 2020
return expr;
const visConfig = buildVisConfig.tagcloud(schemas);

const visdimensionMetric = visConfig.metric
Copy link
Member

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) => {
Copy link
Member

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

Copy link
Member

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 =
Copy link
Member

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);
Copy link
Member

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));
Copy link
Member

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 };
Copy link
Member

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

Copy link
Member

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 }) => {
Copy link
Member

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(
Copy link
Member

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 };
Copy link
Member

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

@lukeelmers lukeelmers mentioned this pull request May 7, 2020
6 tasks
@lukeelmers lukeelmers mentioned this pull request Sep 28, 2020
3 tasks
@lukeelmers
Copy link
Member Author

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.

@lukeelmers lukeelmers closed this Sep 28, 2020
@lukeelmers lukeelmers deleted the fix/build-pipeline branch February 11, 2021 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rewrite pipeline builder
3 participants