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

[Expressions] Variables should be available to sub-expressions #68714

Closed
wylieconlon opened this issue Jun 9, 2020 · 3 comments · Fixed by #71644
Closed

[Expressions] Variables should be available to sub-expressions #68714

wylieconlon opened this issue Jun 9, 2020 · 3 comments · Fixed by #71644
Assignees
Labels
enhancement New value added to drive a business result Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline)

Comments

@wylieconlon
Copy link
Contributor

It is currently not possible to set a variable that is used by a sub-expression. This came up recently when looking at how we could move away from the custom lens_multitable implementation.

For example, I would expect this to work:

kibana
| kibana_context
| var_set name="hello" value={esaggs ...}
| lens_xy_expression table={var name="hello"}

There are workarounds we can use for this problem, specifically we could change the example above to:

kibana
| kibana_context
| var_set name="hello" value={esaggs ...}
| lens_xy_expression table_var="hello"
@wylieconlon wylieconlon added Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) Team:AppArch labels Jun 9, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@lukeelmers
Copy link
Member

FWIW, at one point there was a proposal to make variables a first-class concept in the expression grammar & treat them like scope in JS, which might look something like this:

kibana
| kibana_context
| $hello={esaggs ...}
| lens_xy_expression table={$hello}

I don't think we ever went too far exploring this as the var and var_set workarounds were sufficient to begin with and didn't require changing the grammar, but perhaps it is worth revisiting that discussion.

@lukeelmers lukeelmers added the enhancement New value added to drive a business result label Jun 9, 2020
@ppisljar
Copy link
Member

ppisljar commented Jul 7, 2020

i think its worth looking into why the example above doesn't work as it should and fixing that.

we can still look into changing grammar but i think that should be done independent from fixing this.
technically changing the grammar could/would work exactly the same. AST parser will most likely convert the special $grammar to specific function call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants