-
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.search] Clean up arguments to esaggs. #84973
Merged
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
83e9d4b
Add i18n for argument help text.
lukeelmers f86623e
Remove includeFormatHint arg.
lukeelmers 2a879c2
Update index arg to use indexPatternLoad subexpression.
lukeelmers 09a9296
Export function type mapping & adjust logic in `toExpresionAst`.
lukeelmers 91f6972
Update esaggs to take aggs as subexpressions.
lukeelmers d646f9e
Update vis types to use agg subexpressions.
lukeelmers 256d7b1
Fix vislib regression from #80744.
lukeelmers 782696e
Update lens datasource to build aggs as subexpressions.
lukeelmers e739485
Update interpreter functional tests.
lukeelmers 96d12d4
Add esaggs & request handler unit tests.
lukeelmers 7a07b7f
Update generated docs.
lukeelmers 8e258ec
Fix bug where we didn't shim total hits in search source on the server.
lukeelmers 1e086ee
Fix bug where AbortController was not polyfilled on the server.
lukeelmers 18f62e0
Add interpreter functional tests on the server.
lukeelmers 061748a
Revert lens migration test changes.
lukeelmers d4037ed
Ensure min_doc_count set to false in lens histograms.
lukeelmers 35a6923
Merge branch 'master' into feat/esaggs-args
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Export function type mapping & adjust logic in
toExpresionAst
.
- Loading branch information
commit 09a92960a29cc93694ee530c58387a08b718bea8
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ import { Assign, Ensure } from '@kbn/utility-types'; | |
|
||
import { ISearchOptions, ISearchSource } from 'src/plugins/data/public'; | ||
import { | ||
ExpressionAstFunction, | ||
ExpressionAstExpression, | ||
ExpressionAstArgument, | ||
SerializedFieldFormat, | ||
} from 'src/plugins/expressions/common'; | ||
|
@@ -316,9 +316,9 @@ export class AggConfig { | |
} | ||
|
||
/** | ||
* @returns Returns an ExpressionAst representing the function for this agg type. | ||
* @returns Returns an ExpressionAst representing the this agg type. | ||
*/ | ||
toExpressionAst(): ExpressionAstFunction | undefined { | ||
toExpressionAst(): ExpressionAstExpression | undefined { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discovered that returning an |
||
const functionName = this.type && this.type.expressionName; | ||
const { type, ...rest } = this.serialize(); | ||
if (!functionName || !rest.params) { | ||
|
@@ -334,13 +334,16 @@ export class AggConfig { | |
// If the param provides `toExpressionAst`, we call it with the value | ||
const paramExpressionAst = deserializedParam.toExpressionAst(this.getParam(key)); | ||
if (paramExpressionAst) { | ||
acc[key] = [ | ||
{ | ||
type: 'expression', | ||
chain: [paramExpressionAst], | ||
}, | ||
]; | ||
acc[key] = [paramExpressionAst]; | ||
} | ||
} else if (value && Array.isArray(value)) { | ||
// For array params which don't provide `toExpressionAst`, we stringify | ||
// if it's an array of objects, otherwise we keep it as-is | ||
const definedValues = value.filter( | ||
(v) => typeof v !== 'undefined' && v !== null | ||
) as ExpressionAstArgument[]; | ||
acc[key] = | ||
typeof definedValues[0] === 'object' ? [JSON.stringify(definedValues)] : definedValues; | ||
} else if (typeof value === 'object') { | ||
// For object params which don't provide `toExpressionAst`, we stringify | ||
acc[key] = [JSON.stringify(value)]; | ||
|
@@ -353,15 +356,20 @@ export class AggConfig { | |
}, {} as Record<string, ExpressionAstArgument[]>); | ||
|
||
return { | ||
type: 'function', | ||
function: functionName, | ||
arguments: { | ||
...params, | ||
// Expression args which are provided to all functions | ||
id: [this.id], | ||
enabled: [this.enabled], | ||
...(this.schema ? { schema: [this.schema] } : {}), // schema may be undefined | ||
}, | ||
type: 'expression', | ||
chain: [ | ||
{ | ||
type: 'function', | ||
function: functionName, | ||
arguments: { | ||
...params, | ||
// Expression args which are provided to all functions | ||
id: [this.id], | ||
enabled: [this.enabled], | ||
...(this.schema ? { schema: [this.schema] } : {}), // schema may be undefined | ||
}, | ||
}, | ||
], | ||
}; | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Uncovered a bug in
toExpressionAst
where thepercents
arg was incorrectly stringified when we should have preserved it, so I updated the logic to handle this case where a param is already an array, but not an object array.