mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[ES|QL] Tuples followup cleanup (#224650)
## Summary Minor followup cleanup after https://github.com/elastic/kibana/pull/224530 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
This commit is contained in:
parent
b33c211b5b
commit
cb918fcfb9
7 changed files with 13 additions and 8 deletions
|
@ -123,9 +123,9 @@ export const binaryExpressionGroup = (node: ESQLAstNode): BinaryExpressionGroup
|
||||||
case '>=':
|
case '>=':
|
||||||
return BinaryExpressionGroup.comparison;
|
return BinaryExpressionGroup.comparison;
|
||||||
case 'like':
|
case 'like':
|
||||||
case 'not_like':
|
case 'not like':
|
||||||
case 'rlike':
|
case 'rlike':
|
||||||
case 'not_rlike':
|
case 'not rlike':
|
||||||
return BinaryExpressionGroup.regex;
|
return BinaryExpressionGroup.regex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,10 +109,14 @@ describe('list expressions', () => {
|
||||||
describe('tuple list', () => {
|
describe('tuple list', () => {
|
||||||
test('can print comments around the tuple', () => {
|
test('can print comments around the tuple', () => {
|
||||||
assertPrint('FROM a | WHERE b IN /* 1 */ /* 2 */ (1, 2, 3) /* 3 */');
|
assertPrint('FROM a | WHERE b IN /* 1 */ /* 2 */ (1, 2, 3) /* 3 */');
|
||||||
|
assertPrint('FROM a | WHERE b NOT IN /* 1 */ /* 2 */ (1, 2, 3) /* 3 */');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can print comments inside the tuple', () => {
|
test('can print comments inside the tuple', () => {
|
||||||
assertPrint('FROM a | WHERE b IN (/* 1 */ 1 /* 2 */, /* 3 */ 2 /* 4 */, /* 5 */ 3 /* 6 */)');
|
assertPrint('FROM a | WHERE b IN (/* 1 */ 1 /* 2 */, /* 3 */ 2 /* 4 */, /* 5 */ 3 /* 6 */)');
|
||||||
|
assertPrint(
|
||||||
|
'FROM a | WHERE b NOT IN (/* 1 */ 1 /* 2 */, /* 3 */ 2 /* 4 */, /* 5 */ 3 /* 6 */)'
|
||||||
|
);
|
||||||
assertPrint(
|
assertPrint(
|
||||||
'FROM a | WHERE b IN /* 0 */ (/* 1 */ 1 /* 2 */, /* 3 */ 2 /* 4 */, /* 5 */ 3 /* 6 */) /* 7 */'
|
'FROM a | WHERE b IN /* 0 */ (/* 1 */ 1 /* 2 */, /* 3 */ 2 /* 4 */, /* 5 */ 3 /* 6 */) /* 7 */'
|
||||||
);
|
);
|
||||||
|
|
|
@ -691,10 +691,12 @@ describe('single line query', () => {
|
||||||
describe('tuple lists', () => {
|
describe('tuple lists', () => {
|
||||||
test('empty list', () => {
|
test('empty list', () => {
|
||||||
expect(reprint('FROM a | WHERE b IN ()').text).toBe('FROM a | WHERE b IN ()');
|
expect(reprint('FROM a | WHERE b IN ()').text).toBe('FROM a | WHERE b IN ()');
|
||||||
|
expect(reprint('FROM a | WHERE b NOT IN ()').text).toBe('FROM a | WHERE b NOT IN ()');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('one element list', () => {
|
test('one element list', () => {
|
||||||
expect(reprint('FROM a | WHERE b IN (1)').text).toBe('FROM a | WHERE b IN (1)');
|
expect(reprint('FROM a | WHERE b IN (1)').text).toBe('FROM a | WHERE b IN (1)');
|
||||||
|
expect(reprint('FROM a | WHERE b NOT IN (1)').text).toBe('FROM a | WHERE b NOT IN (1)');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('three element list', () => {
|
test('three element list', () => {
|
||||||
|
|
|
@ -447,7 +447,7 @@ ROW
|
||||||
describe('list tuple expressions', () => {
|
describe('list tuple expressions', () => {
|
||||||
test('numeric list literal, surrounded from three sides', () => {
|
test('numeric list literal, surrounded from three sides', () => {
|
||||||
assertReprint(`FROM a | WHERE b IN ()`);
|
assertReprint(`FROM a | WHERE b IN ()`);
|
||||||
assertReprint(`FROM a | WHERE b IN (/* 1 */ 123456789 /* 2 */)`);
|
assertReprint(`FROM a | WHERE b NOT IN (/* 1 */ 123456789 /* 2 */)`);
|
||||||
assertReprint(`FROM a
|
assertReprint(`FROM a
|
||||||
| WHERE
|
| WHERE
|
||||||
b IN
|
b IN
|
||||||
|
|
|
@ -1038,13 +1038,13 @@ FROM a
|
||||||
|
|
||||||
test('breaks lists with long items', () => {
|
test('breaks lists with long items', () => {
|
||||||
const query =
|
const query =
|
||||||
'FROM a | WHERE b in ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")';
|
'FROM a | WHERE b not in ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")';
|
||||||
const text = reprint(query).text;
|
const text = reprint(query).text;
|
||||||
|
|
||||||
expect('\n' + text).toBe(`
|
expect('\n' + text).toBe(`
|
||||||
FROM a
|
FROM a
|
||||||
| WHERE
|
| WHERE
|
||||||
b IN
|
b NOT IN
|
||||||
(
|
(
|
||||||
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
|
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
|
||||||
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
|
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
|
||||||
|
|
|
@ -230,11 +230,11 @@ export type BinaryExpressionOperator =
|
||||||
export type BinaryExpressionArithmeticOperator = '+' | '-' | '*' | '/' | '%';
|
export type BinaryExpressionArithmeticOperator = '+' | '-' | '*' | '/' | '%';
|
||||||
export type BinaryExpressionAssignmentOperator = '=';
|
export type BinaryExpressionAssignmentOperator = '=';
|
||||||
export type BinaryExpressionComparisonOperator = '==' | '=~' | '!=' | '<' | '<=' | '>' | '>=';
|
export type BinaryExpressionComparisonOperator = '==' | '=~' | '!=' | '<' | '<=' | '>' | '>=';
|
||||||
export type BinaryExpressionRegexOperator = 'like' | 'not_like' | 'rlike' | 'not_rlike';
|
export type BinaryExpressionRegexOperator = 'like' | 'not like' | 'rlike' | 'not rlike';
|
||||||
export type BinaryExpressionRenameOperator = 'as';
|
export type BinaryExpressionRenameOperator = 'as';
|
||||||
export type BinaryExpressionWhereOperator = 'where';
|
export type BinaryExpressionWhereOperator = 'where';
|
||||||
export type BinaryExpressionMatchOperator = ':';
|
export type BinaryExpressionMatchOperator = ':';
|
||||||
export type BinaryExpressionIn = 'in' | 'not_in';
|
export type BinaryExpressionIn = 'in' | 'not in';
|
||||||
|
|
||||||
// from https://github.com/elastic/elasticsearch/blob/122e7288200ee03e9087c98dff6cebbc94e774aa/docs/reference/esql/functions/kibana/inline_cast.json
|
// from https://github.com/elastic/elasticsearch/blob/122e7288200ee03e9087c98dff6cebbc94e774aa/docs/reference/esql/functions/kibana/inline_cast.json
|
||||||
export type InlineCastingType =
|
export type InlineCastingType =
|
||||||
|
|
|
@ -38,7 +38,6 @@ import {
|
||||||
unwrapArrayOneLevel,
|
unwrapArrayOneLevel,
|
||||||
isArrayType,
|
isArrayType,
|
||||||
isParametrized,
|
isParametrized,
|
||||||
// isParam,
|
|
||||||
} from '../shared/helpers';
|
} from '../shared/helpers';
|
||||||
import { getMessageFromId, errors } from './errors';
|
import { getMessageFromId, errors } from './errors';
|
||||||
import { getMaxMinNumberOfParams, collapseWrongArgumentTypeMessages } from './helpers';
|
import { getMaxMinNumberOfParams, collapseWrongArgumentTypeMessages } from './helpers';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue