-
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
[ES|QL] METRICS
command definition and validation
#184905
Merged
vadimkibana
merged 92 commits into
elastic:main
from
vadimkibana:esql-metrics-definitions
Jun 20, 2024
Merged
Changes from 80 commits
Commits
Show all changes
92 commits
Select commit
Hold shift + click to select a range
3a9a5de
add basic validation test cases
vadimkibana bbc0540
add initial command definition
vadimkibana ced48fc
add more basic tests
vadimkibana 965ea88
group metrics and from tests
vadimkibana 8dbfcca
support aggregation functions in metrics command
vadimkibana 7bf1203
add standalone metrics tests
vadimkibana 9bb3dcc
move from command tests into subfolder
vadimkibana 8317155
remove metrics test from the main validation file
vadimkibana e837471
add metrics to builtins definition
vadimkibana 5f8d096
setup grouping and aggregates tests
vadimkibana 57a9415
setup metrics aggregates and grouping validation
vadimkibana 8582d3e
rename metrics command indices to sources
vadimkibana ce1ba83
move from command tests to its own file
vadimkibana 0ec92c3
adjust test titles
vadimkibana f4cca4f
move stats tests into a separate file
vadimkibana 2601b9e
improve test assertion
vadimkibana 13c66a9
cleanup metrics tests
vadimkibana a68a5f7
implement walker
vadimkibana 8ed1724
expose walker
vadimkibana cdc4b97
continue on metrics validation
vadimkibana 7ee91b6
improve walker, add smoke test
vadimkibana b4391c0
harder types for field collection
vadimkibana 2f2acc6
error on missing aggregation function
vadimkibana 81e8d69
cleanup tests and error message
vadimkibana 0ce1161
validate that aggregate expressions are aggregation-closed
vadimkibana bf75ded
emit error when aggregate expression is a column
vadimkibana 2131b02
cleanup unknown agg function factory
vadimkibana 76cfe0e
improve function definition
vadimkibana ae956d4
populate variables with aggregated fields
vadimkibana 8e420de
automated test snapshot update
vadimkibana 98df644
cleanup unknown column errors
vadimkibana ab97b79
create shared variable collection function
vadimkibana 725d9ea
enable all metrics tests
vadimkibana f515e6c
add metrics function validation support
vadimkibana 50cb9ec
fix double unknown function error
vadimkibana 5048cf1
add more metrics tests
vadimkibana df65c06
improve command definition
vadimkibana 9dbaec5
Merge remote-tracking branch 'upstream/main' into esql-metrics-defini…
vadimkibana ca9cb97
Merge branch 'main' into esql-metrics-definitions
vadimkibana e42ed51
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine afd8160
format code as per linter
vadimkibana 8efa81b
fix linter warnings
vadimkibana db534b1
Merge remote-tracking branch 'origin/esql-metrics-definitions' into e…
vadimkibana 1bc4754
Merge branch 'main' into esql-metrics-definitions
kibanamachine 760abc5
move walker to the autocomplete and validation package
vadimkibana d6cbb1b
typos
vadimkibana b23f34e
create higher-order function for collection errors
vadimkibana d48c106
add ability to collect test cases to a fixture file
vadimkibana 7194a37
collect test fixtures from executed tests
vadimkibana cc1fc91
add jsdocs to test helpers
vadimkibana 3f8c617
separate from command test suite into own file
vadimkibana 02240b3
new naming for autogenerated files
vadimkibana d28b023
collect from command tests into main fixture file
vadimkibana 6fbfefa
remove metrics dupes
vadimkibana a239636
add metrics supported command in generator file
vadimkibana 31505ec
larger "do not edit" warning
vadimkibana 2fe90f6
js ts
vadimkibana f3d7d92
Merge branch 'main' into esql-metrics-definitions
kibanamachine 705f907
make agg close check function more readable
vadimkibana 180aa25
use snake case file names
vadimkibana b3b3cee
setup jest integration testing for validation and autocomplete
vadimkibana ebec8d9
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 084b923
improve integration test suite
vadimkibana eed37fd
separate FROM callback tests into its own file
vadimkibana 83b6dac
augment fields as in the legacy test file
vadimkibana 3e7986c
cleanup integration test implementation
vadimkibana 508086b
test all number and string type combination
vadimkibana e716a1c
consolidate esql test env setup
vadimkibana af8248a
add comments
vadimkibana d004d83
move helpers into a separate file
vadimkibana 959b665
cleanup integration tests and rename from test suite
vadimkibana e47b8d6
create test suites for stats and metrics commands
vadimkibana 90d170a
remove test case collection to .json
vadimkibana a509c16
remove autogenerated .json files
vadimkibana c28ab5b
error on nested aggregation functions
vadimkibana 9717ac4
exit early on first found agg-in-agg error
vadimkibana 1b05483
add extra success metrics test
vadimkibana bc03874
use FROM command to use METRICS fields
vadimkibana 04fbf71
Merge remote-tracking branch 'upstream/main' into esql-metrics-defini…
vadimkibana bbc273a
rerun validation tests
vadimkibana b1eb61b
remove defensive coding check
vadimkibana cad62b1
ignore open handles as "core.setup()" does not close something
vadimkibana dc653d9
Merge remote-tracking branch 'upstream/main' into esql-metrics-defini…
vadimkibana 02d525f
rename function
vadimkibana 9131be3
Merge remote-tracking branch 'upstream/main' into esql-metrics-defini…
vadimkibana fa198f3
update tests
vadimkibana 587d9ea
Merge remote-tracking branch 'upstream/main' into esql-metrics-defini…
vadimkibana 341713e
rerun unit tests
vadimkibana 7e98030
use ast walker implementation
vadimkibana f065d9f
skip integration tests
vadimkibana fce4bc0
remove circular dependency
vadimkibana 7715403
fix type check error
vadimkibana 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
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
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 |
---|---|---|
|
@@ -44,7 +44,7 @@ import { | |
import { getPosition } from './ast_position_utils'; | ||
import { | ||
collectAllSourceIdentifiers, | ||
collectAllFieldsStatements, | ||
collectAllFields, | ||
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. Removed "Statements" suffix, as it fields are more like "expressions". |
||
visitByOption, | ||
collectAllColumnIdentifiers, | ||
visitRenameClauses, | ||
|
@@ -120,7 +120,7 @@ export class AstListener implements ESQLParserListener { | |
exitRowCommand(ctx: RowCommandContext) { | ||
const command = createCommand('row', ctx); | ||
this.ast.push(command); | ||
command.args.push(...collectAllFieldsStatements(ctx.fields())); | ||
command.args.push(...collectAllFields(ctx.fields())); | ||
} | ||
|
||
/** | ||
|
@@ -153,20 +153,20 @@ export class AstListener implements ESQLParserListener { | |
...createAstBaseItem('metrics', ctx), | ||
type: 'command', | ||
args: [], | ||
indices: ctx | ||
sources: ctx | ||
.getTypedRuleContexts(IndexIdentifierContext) | ||
.map((sourceCtx) => createSource(sourceCtx)), | ||
}; | ||
this.ast.push(node); | ||
const aggregates = collectAllFieldsStatements(ctx.fields(0)); | ||
const grouping = collectAllFieldsStatements(ctx.fields(1)); | ||
const aggregates = collectAllFields(ctx.fields(0)); | ||
const grouping = collectAllFields(ctx.fields(1)); | ||
if (aggregates && aggregates.length) { | ||
node.aggregates = aggregates; | ||
} | ||
if (grouping && grouping.length) { | ||
node.grouping = grouping; | ||
} | ||
node.args.push(...node.indices, ...aggregates, ...grouping); | ||
node.args.push(...node.sources, ...aggregates, ...grouping); | ||
} | ||
|
||
/** | ||
|
@@ -176,7 +176,7 @@ export class AstListener implements ESQLParserListener { | |
exitEvalCommand(ctx: EvalCommandContext) { | ||
const commandAst = createCommand('eval', ctx); | ||
this.ast.push(commandAst); | ||
commandAst.args.push(...collectAllFieldsStatements(ctx.fields())); | ||
commandAst.args.push(...collectAllFields(ctx.fields())); | ||
} | ||
|
||
/** | ||
|
@@ -189,7 +189,7 @@ export class AstListener implements ESQLParserListener { | |
|
||
// STATS expression is optional | ||
if (ctx._stats) { | ||
command.args.push(...collectAllFieldsStatements(ctx.fields(0))); | ||
command.args.push(...collectAllFields(ctx.fields(0))); | ||
} | ||
if (ctx._grouping) { | ||
command.args.push(...visitByOption(ctx, ctx._stats ? ctx.fields(1) : ctx.fields(0))); | ||
|
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
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
13 changes: 13 additions & 0 deletions
13
packages/kbn-esql-validation-autocomplete/jest.integration.config.js
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
module.exports = { | ||
preset: '@kbn/test/jest_integration_node', | ||
rootDir: '../..', | ||
roots: ['<rootDir>/packages/kbn-esql-validation-autocomplete'], | ||
}; |
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
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
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.
I thought "sources" is more accurate name for this field.