Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
0e937a9
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Feb 6, 2025
7ffbf4c
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Feb 10, 2025
b426318
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Feb 13, 2025
511ccaa
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Feb 14, 2025
2d71300
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Feb 18, 2025
0076de9
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Feb 21, 2025
2898ce1
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Feb 24, 2025
ace0009
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Mar 3, 2025
6cdd8c1
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Mar 4, 2025
98616e9
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Mar 6, 2025
64e40fd
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Mar 7, 2025
1e3f8d1
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Mar 11, 2025
afd5630
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Mar 13, 2025
31c6cb3
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Mar 18, 2025
08f4b1b
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Mar 18, 2025
0c11f55
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Mar 20, 2025
de2bc7a
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Mar 21, 2025
828d142
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Mar 25, 2025
34bd1ef
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Apr 1, 2025
f0070c6
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Apr 3, 2025
16a27c7
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Apr 3, 2025
cde697e
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Apr 8, 2025
8b66178
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Apr 10, 2025
3555b0c
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Apr 14, 2025
57a5f4a
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Apr 16, 2025
420eb2b
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Apr 29, 2025
8e5e4a8
Merge branch 'main' of github.com:elastic/kibana
drewdaemon May 5, 2025
141765f
Merge branch 'main' of github.com:elastic/kibana
drewdaemon May 21, 2025
cdf4d20
Merge branch 'main' of github.com:elastic/kibana
drewdaemon May 23, 2025
d177eb1
Merge branch 'main' of github.com:elastic/kibana
drewdaemon May 28, 2025
4fd1791
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Jun 4, 2025
aa1c776
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Jun 5, 2025
5fe324c
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Jun 9, 2025
6dfd40a
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Jul 15, 2025
5b804dc
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Jul 17, 2025
072394a
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Jul 23, 2025
b0929bf
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Jul 29, 2025
e1611aa
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Jul 30, 2025
11f4fe9
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Jul 31, 2025
e99f812
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Aug 4, 2025
c391d71
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Aug 6, 2025
396a0a0
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Aug 7, 2025
06b4324
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Aug 25, 2025
4d175f2
Merge branch 'main' of github.com:elastic/kibana
drewdaemon Aug 27, 2025
ac2fd06
suggest user-defined columns in multi-expression EVAL statements
drewdaemon Aug 27, 2025
e532b90
casing
drewdaemon Aug 27, 2025
23493d7
compute available columns at the level of each command
drewdaemon Aug 27, 2025
ad6fb08
Merge branch 'main' of github.com:elastic/kibana into align-column-ex…
drewdaemon Aug 28, 2025
0b47038
Merge branch 'main' of github.com:elastic/kibana into align-column-ex…
drewdaemon Aug 28, 2025
4359764
start to unify column types
drewdaemon Aug 28, 2025
27712b1
columns-after for EVAL
drewdaemon Aug 28, 2025
e10bac4
STATS and INLINESTATS columns-after
drewdaemon Aug 28, 2025
b9ddc0a
reuse stats columns after in inlinestats
drewdaemon Aug 29, 2025
48657cb
Clean up
drewdaemon Aug 29, 2025
e735671
Unify column lists
drewdaemon Aug 29, 2025
78d31d5
fix most non-test type errors
drewdaemon Aug 29, 2025
b0d09e3
Merge branch 'main' of github.com:elastic/kibana into align-column-ex…
drewdaemon Aug 29, 2025
f868d8b
fix change_point
drewdaemon Aug 29, 2025
e7cc989
fix completion
drewdaemon Aug 29, 2025
3401a13
fix dissect
drewdaemon Aug 29, 2025
4ddff61
fix drop
drewdaemon Aug 29, 2025
162ff70
make eval work
drewdaemon Aug 29, 2025
15f51b9
add query to the signature
drewdaemon Aug 29, 2025
5000798
fix rename
drewdaemon Aug 29, 2025
0c0b6fc
fork plus an eval fix
drewdaemon Aug 29, 2025
81a240c
grok
drewdaemon Sep 2, 2025
6e428be
keep
drewdaemon Sep 2, 2025
f2afdee
stats working
drewdaemon Sep 2, 2025
1942b3b
remove context from columns-after call signature
drewdaemon Sep 3, 2025
696c468
FIXME for EVAL validation
drewdaemon Sep 3, 2025
6eb82c4
skip validation for new columns
drewdaemon Sep 4, 2025
8ac4f19
validate by subquery
drewdaemon Sep 4, 2025
eaa98cb
Merge branch 'main' of github.com:elastic/kibana into align-column-ex…
drewdaemon Sep 4, 2025
addabd1
support join fields
drewdaemon Sep 4, 2025
21e1ec2
enrich mostly working
drewdaemon Sep 4, 2025
5c56945
support renaming in WITH
drewdaemon Sep 4, 2025
54e813d
resolve type issues
drewdaemon Sep 4, 2025
7bd868c
JOIN and ENRICH within FORK
drewdaemon Sep 5, 2025
4b36c06
Fix enrich validation
drewdaemon Sep 5, 2025
3172e2f
fix change_point validation
drewdaemon Sep 5, 2025
21e5453
dedupe eval expansion
drewdaemon Sep 5, 2025
0412eb5
move some utils
drewdaemon Sep 5, 2025
e997976
comment cleanup
drewdaemon Sep 5, 2025
8a40764
infer expression column names from the original query text, preservin…
drewdaemon Sep 5, 2025
cd00f66
make more tests pass
drewdaemon Sep 5, 2025
d7f56e4
restore a small check
drewdaemon Sep 5, 2025
1395887
Merge branch 'main' of github.com:elastic/kibana into align-column-ex…
drewdaemon Sep 8, 2025
b6182a1
Fix ast package tests
drewdaemon Sep 8, 2025
38a8fc0
make source commands non-exceptional
drewdaemon Sep 8, 2025
b1325c3
swap from and show
drewdaemon Sep 8, 2025
e37f27e
fix mo tests
drewdaemon Sep 8, 2025
cd77e16
remove comment
drewdaemon Sep 8, 2025
dc7698c
fix type issue
drewdaemon Sep 8, 2025
a0708fc
Merge branch 'main' of github.com:elastic/kibana into align-column-ex…
drewdaemon Sep 9, 2025
f5437e9
fix inlinestats
drewdaemon Sep 9, 2025
c838166
remove superfluous validation
drewdaemon Sep 9, 2025
a6857e6
PR feedback
drewdaemon Sep 9, 2025
0b9e6ff
fix TS
drewdaemon Sep 9, 2025
c7a8428
remove fixmes
drewdaemon Sep 9, 2025
0b1d93f
clean unused var
drewdaemon Sep 9, 2025
74432cb
update stats to inline-stats
drewdaemon Sep 10, 2025
f64c58e
remove target column from rerank validation list
drewdaemon Sep 10, 2025
383cdbd
remove _fork column setting
drewdaemon Sep 10, 2025
f025cd1
update location 🙄
drewdaemon Sep 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ const ESQLEditorInternal = function ESQLEditor({
name: c.name,
type: c.meta.esType as FieldType,
hasConflict: c.meta.type === KBN_FIELD_TYPES.CONFLICT,
userDefined: false,
};
}) || [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
import { uniq } from 'lodash';
import type { LicenseType } from '@kbn/licensing-types';
import type {
ESQLUserDefinedColumn,
ESQLFieldWithMetadata,
ICommandCallbacks,
ISuggestionItem,
Location,
ESQLColumnData,
} from '../commands_registry/types';
import { getLocationFromCommandOrOptionName } from '../commands_registry/types';
import { aggFunctionDefinitions } from '../definitions/generated/aggregation_functions';
Expand Down Expand Up @@ -50,8 +49,7 @@ export const suggest = (
arg1: ESQLCommand,
arg2: ICommandCallbacks,
arg3: {
userDefinedColumns: Map<string, ESQLUserDefinedColumn[]>;
fields: Map<string, ESQLFieldWithMetadata>;
columns: Map<string, ESQLColumnData>;
},
arg4?: number
) => Promise<ISuggestionItem[]>,
Expand Down Expand Up @@ -80,8 +78,7 @@ export const expectSuggestions = async (
arg1: ESQLCommand,
arg2: ICommandCallbacks,
arg3: {
userDefinedColumns: Map<string, ESQLUserDefinedColumn[]>;
fields: Map<string, ESQLFieldWithMetadata>;
columns: Map<string, ESQLColumnData>;
},
arg4?: number
) => Promise<ISuggestionItem[]>,
Expand All @@ -105,12 +102,10 @@ export function getFieldNamesByType(
_requestedType: Readonly<FieldType | 'any' | Array<FieldType | 'any'>>,
excludeUserDefined: boolean = false
) {
const fieldsMap = mockContext.fields;
const userDefinedColumnsMap = mockContext.userDefinedColumns;
const fields = Array.from(fieldsMap.values());
const userDefinedColumns = Array.from(userDefinedColumnsMap.values()).flat();
const columnMap = mockContext.columns;
const columns = Array.from(columnMap.values());
const requestedType = Array.isArray(_requestedType) ? _requestedType : [_requestedType];
const finalArray = excludeUserDefined ? fields : [...fields, ...userDefinedColumns];
const finalArray = excludeUserDefined ? columns.filter((col) => !col.userDefined) : columns;
return finalArray
.filter(
({ type }) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
*/
import type { IndexAutocompleteItem, InferenceEndpointAutocompleteItem } from '@kbn/esql-types';
import type {
ESQLFieldWithMetadata,
ESQLColumnData,
ESQLPolicy,
ESQLUserDefinedColumn,
ICommandCallbacks,
ICommandContext,
} from '../commands_registry/types';
Expand Down Expand Up @@ -115,84 +114,79 @@ export const editorExtensions = {
};

export const mockContext: ICommandContext = {
userDefinedColumns: new Map<string, ESQLUserDefinedColumn[]>([
columns: new Map<string, ESQLColumnData>([
[
'var0',
[
{
name: 'var0',
type: 'double',
location: { min: 0, max: 10 },
},
],
{
name: 'var0',
type: 'double',
location: { min: 0, max: 10 },
userDefined: true,
},
],
[
'col0',
[
{
name: 'col0',
type: 'double',
location: { min: 0, max: 10 },
},
],
{
name: 'col0',
type: 'double',
location: { min: 0, max: 10 },
userDefined: true,
},
],
[
'prompt',
[
{
name: 'prompt',
type: 'keyword',
location: { min: 0, max: 10 },
},
],
{
name: 'prompt',
type: 'keyword',
location: { min: 0, max: 10 },
userDefined: true,
},
],
[
'integerPrompt',
[
{
name: 'integerPrompt',
type: 'integer',
location: { min: 0, max: 10 },
},
],
{
name: 'integerPrompt',
type: 'integer',
location: { min: 0, max: 10 },
userDefined: true,
},
],
[
'ipPrompt',
[
{
name: 'ipPrompt',
type: 'ip',
location: { min: 0, max: 10 },
},
],
{
name: 'ipPrompt',
type: 'ip',
location: { min: 0, max: 10 },
userDefined: true,
},
],
[
'renamedField',
[
{
name: 'renamedField',
type: 'keyword',
location: { min: 0, max: 10 },
},
],
{
name: 'renamedField',
type: 'keyword',
location: { min: 0, max: 10 },
userDefined: true,
},
],
]),
fields: new Map<string, ESQLFieldWithMetadata>([
['keywordField', { name: 'keywordField', type: 'keyword' }],
['any#Char$Field', { name: 'any#Char$Field', type: 'keyword' }],
['textField', { name: 'textField', type: 'text' }],
['doubleField', { name: 'doubleField', type: 'double' }],
['integerField', { name: 'integerField', type: 'integer' }],
['counterIntegerField', { name: 'counterIntegerField', type: 'counter_integer' }],
['dateField', { name: 'dateField', type: 'date' }],
['dateNanosField', { name: 'dateNanosField', type: 'date_nanos' }],
['@timestamp', { name: '@timestamp', type: 'date' }],
['ipField', { name: 'ipField', type: 'ip' }],
['booleanField', { name: 'booleanField', type: 'boolean' }],
['geoPointField', { name: 'geoPointField', type: 'geo_point' }],
['geoShapeField', { name: 'geoShapeField', type: 'geo_shape' }],
['versionField', { name: 'versionField', type: 'version' }],
['longField', { name: 'longField', type: 'long' }],
['keywordField', { name: 'keywordField', type: 'keyword', userDefined: false }],
['any#Char$Field', { name: 'any#Char$Field', type: 'keyword', userDefined: false }],
['textField', { name: 'textField', type: 'text', userDefined: false }],
['doubleField', { name: 'doubleField', type: 'double', userDefined: false }],
['integerField', { name: 'integerField', type: 'integer', userDefined: false }],
[
'counterIntegerField',
{ name: 'counterIntegerField', type: 'counter_integer', userDefined: false },
],
['dateField', { name: 'dateField', type: 'date', userDefined: false }],
['dateNanosField', { name: 'dateNanosField', type: 'date_nanos', userDefined: false }],
['@timestamp', { name: '@timestamp', type: 'date', userDefined: false }],
['ipField', { name: 'ipField', type: 'ip', userDefined: false }],
['booleanField', { name: 'booleanField', type: 'boolean', userDefined: false }],
['geoPointField', { name: 'geoPointField', type: 'geo_point', userDefined: false }],
['geoShapeField', { name: 'geoShapeField', type: 'geo_shape', userDefined: false }],
['versionField', { name: 'versionField', type: 'version', userDefined: false }],
['longField', { name: 'longField', type: 'long', userDefined: false }],
]),
policies: new Map<string, ESQLPolicy>(policies.map((policy) => [policy.name, policy])),
sources: indexes.map((name) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import type { ESQLUserDefinedColumn, ESQLFieldWithMetadata } from '../commands_registry/types';
import type { ESQLColumnData } from '../commands_registry/types';
import { Parser } from '../parser';
import type { ESQLCommand, ESQLMessage } from '../types';
import { mockContext } from './context_fixtures';
Expand All @@ -28,8 +28,7 @@ export const expectErrors = (
arg0: ESQLCommand,
arg1: ESQLCommand[],
arg2: {
userDefinedColumns: Map<string, ESQLUserDefinedColumn[]>;
fields: Map<string, ESQLFieldWithMetadata>;
columns: Map<string, ESQLColumnData>;
}
) => any
) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,48 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { synth } from '../../../..';
import type { ESQLFieldWithMetadata, ESQLUserDefinedColumn } from '../../types';
import type { ESQLColumnData } from '../../types';
import { columnsAfter } from './columns_after';

describe('CHANGE_POINT > columnsAfter', () => {
const context = {
userDefinedColumns: new Map<string, ESQLUserDefinedColumn[]>([]),
fields: new Map<string, ESQLFieldWithMetadata>([
['field1', { name: 'field1', type: 'keyword' }],
['count', { name: 'count', type: 'double' }],
]),
};
it('adds "type" and "pvalue" fields, when AS option not specified', () => {
const previousCommandFields = [
{ name: 'field1', type: 'keyword' },
{ name: 'count', type: 'double' },
] as ESQLFieldWithMetadata[];
const previousCommandFields: ESQLColumnData[] = [
{ name: 'field1', type: 'keyword', userDefined: false },
{ name: 'count', type: 'double', userDefined: false },
];

const result = columnsAfter(
synth.cmd`CHANGE_POINT count ON field1`,
previousCommandFields,
context
);
const result = columnsAfter(synth.cmd`CHANGE_POINT count ON field1`, previousCommandFields, '');

expect(result).toEqual([
{ name: 'field1', type: 'keyword' },
{ name: 'count', type: 'double' },
{ name: 'type', type: 'keyword' },
{ name: 'pvalue', type: 'double' },
expect(result).toEqual<ESQLColumnData[]>([
{ name: 'field1', type: 'keyword', userDefined: false },
{ name: 'count', type: 'double', userDefined: false },
{ name: 'type', type: 'keyword', userDefined: false },
{ name: 'pvalue', type: 'double', userDefined: false },
]);
});

it('adds the given names as fields, when AS option is specified', () => {
const previousCommandFields = [
{ name: 'field1', type: 'keyword' },
{ name: 'count', type: 'double' },
] as ESQLFieldWithMetadata[];
const previousCommandFields: ESQLColumnData[] = [
{ name: 'field1', type: 'keyword', userDefined: false },
{ name: 'count', type: 'double', userDefined: false },
];

const result = columnsAfter(
synth.cmd`CHANGE_POINT count ON field1 AS changePointType, pValue`,
previousCommandFields,
context
''
);

expect(result).toEqual([
{ name: 'field1', type: 'keyword' },
{ name: 'count', type: 'double' },
{ name: 'changePointType', type: 'keyword' },
{ name: 'pValue', type: 'double' },
expect(result).toEqual<ESQLColumnData[]>([
{ name: 'field1', type: 'keyword', userDefined: false },
{ name: 'count', type: 'double', userDefined: false },
{
name: 'changePointType',
type: 'keyword',
userDefined: true,
location: { min: 0, max: 0 },
},
{ name: 'pValue', type: 'double', userDefined: true, location: { min: 0, max: 0 } },
]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,49 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import uniqBy from 'lodash/uniqBy';
import { type ESQLCommand, type ESQLAstChangePointCommand } from '../../../types';
import { LeafPrinter } from '../../../pretty_print/leaf_printer';
import type { ESQLFieldWithMetadata } from '../../types';
import type { ICommandContext } from '../../types';
import { type ESQLAstChangePointCommand, type ESQLCommand } from '../../../types';
import type { ESQLColumnData } from '../../types';

export const columnsAfter = (
command: ESQLCommand,
previousColumns: ESQLFieldWithMetadata[],
context?: ICommandContext
previousColumns: ESQLColumnData[],
query: string
) => {
const { target } = command as ESQLAstChangePointCommand;

return uniqBy(
[
...previousColumns,
{
name: target ? LeafPrinter.column(target.type) : 'type',
type: 'keyword' as const,
},
{
name: target ? LeafPrinter.column(target.pvalue) : 'pvalue',
type: 'double' as const,
},
],
'name'
);
let typeField: ESQLColumnData;
let pvalueField: ESQLColumnData;

if (target?.type) {
typeField = {
name: LeafPrinter.column(target.type),
type: 'keyword' as const,
userDefined: true,
location: target.type.location,
};
} else {
typeField = {
name: 'type',
type: 'keyword' as const,
userDefined: false,
};
}

if (target?.pvalue) {
pvalueField = {
name: LeafPrinter.column(target.pvalue),
type: 'double' as const,
userDefined: true,
location: target.pvalue.location,
};
} else {
pvalueField = {
name: 'pvalue',
type: 'double' as const,
userDefined: false,
};
}

return uniqBy([...previousColumns, typeField, pvalueField], 'name');
};
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ describe('CHANGE_POINT Validation', () => {

test('raises error when the default @timestamp field is missing', () => {
// make sure that @timestamp field is not present
const newFields = new Map(mockContext.fields);
newFields.delete('@timestamp');
const newColumns = new Map(mockContext.columns);
newColumns.delete('@timestamp');
const context = {
...mockContext,
fields: newFields,
columns: newColumns,
};
changePointExpectErrors(
'FROM a_index | CHANGE_POINT doubleField',
Expand Down
Loading