Skip to content

Commit

Permalink
[kql] Remove named args and unused geo functions (elastic#118973)
Browse files Browse the repository at this point in the history
* [kql] Remove named args and unused geo functions

* Fix tests

* Re-format grammar output
  • Loading branch information
lukasolson authored and TinLe committed Dec 22, 2021
1 parent 8d5b73a commit 62a30ac
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 588 deletions.
4 changes: 1 addition & 3 deletions packages/kbn-es-query/grammar/grammar.peggy
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
const buildFunctionNode = nodeTypes.function.buildNodeWithArgumentNodes;
const buildLiteralNode = nodeTypes.literal.buildNode;
const buildWildcardNode = nodeTypes.wildcard.buildNode;
const buildNamedArgNode = nodeTypes.namedArg.buildNode;
const { wildcardSymbol } = nodeTypes.wildcard;
}

Expand Down Expand Up @@ -100,8 +99,7 @@ FieldRangeExpression
suggestionTypes: ['conjunction']
};
}
const range = buildNamedArgNode(operator, value);
return buildFunctionNode('range', [field, range]);
return buildFunctionNode('range', [field, operator, value]);
}

FieldValueExpression
Expand Down
16 changes: 4 additions & 12 deletions packages/kbn-es-query/src/kuery/ast/ast.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,25 +174,17 @@ describe('kuery AST API', () => {

test('should support exclusive range operators', () => {
const expected = nodeTypes.function.buildNode('and', [
nodeTypes.function.buildNode('range', 'bytes', {
gt: '1000',
}),
nodeTypes.function.buildNode('range', 'bytes', {
lt: '8000',
}),
nodeTypes.function.buildNode('range', 'bytes', 'gt', '1000'),
nodeTypes.function.buildNode('range', 'bytes', 'lt', '8000'),
]);
const actual = fromKueryExpression('bytes > 1000 and bytes < 8000');
expect(actual).toEqual(expected);
});

test('should support inclusive range operators', () => {
const expected = nodeTypes.function.buildNode('and', [
nodeTypes.function.buildNode('range', 'bytes', {
gte: '1000',
}),
nodeTypes.function.buildNode('range', 'bytes', {
lte: '8000',
}),
nodeTypes.function.buildNode('range', 'bytes', 'gte', '1000'),
nodeTypes.function.buildNode('range', 'bytes', 'lte', '8000'),
]);
const actual = fromKueryExpression('bytes >= 1000 and bytes <= 8000');
expect(actual).toEqual(expected);
Expand Down
137 changes: 0 additions & 137 deletions packages/kbn-es-query/src/kuery/functions/geo_bounding_box.test.ts

This file was deleted.

61 changes: 0 additions & 61 deletions packages/kbn-es-query/src/kuery/functions/geo_bounding_box.ts

This file was deleted.

134 changes: 0 additions & 134 deletions packages/kbn-es-query/src/kuery/functions/geo_polygon.test.ts

This file was deleted.

Loading

0 comments on commit 62a30ac

Please sign in to comment.