diff --git a/src/platform/packages/shared/kbn-esql-ast/src/parser/__tests__/change_point.test.ts b/src/platform/packages/shared/kbn-esql-ast/src/parser/__tests__/change_point.test.ts index db493000012d7..03c20cd9644e8 100644 --- a/src/platform/packages/shared/kbn-esql-ast/src/parser/__tests__/change_point.test.ts +++ b/src/platform/packages/shared/kbn-esql-ast/src/parser/__tests__/change_point.test.ts @@ -220,4 +220,33 @@ describe('CHANGE_POINT command', () => { }); }); }); + + describe('incorrectly formatted', () => { + it('throws on missing ON arguments', () => { + const text = `FROM index | CHANGE_POINT value ON`; + const { errors, ast } = EsqlQuery.fromSrc(text); + const option = Walker.match(ast, { type: 'option', name: 'on' }); + + expect(errors.length).toBe(1); + expect(option).toBe(undefined); + }); + + it('throws on missing AS arguments', () => { + const text = `FROM index | CHANGE_POINT value AS`; + const { errors, ast } = EsqlQuery.fromSrc(text); + const option = Walker.match(ast, { type: 'option', name: 'as' }); + + expect(errors.length).toBe(1); + expect(option).toBe(undefined); + }); + + it('throws on missing AS arguments (ON present)', () => { + const text = `FROM index | CHANGE_POINT value ON a AS`; + const { errors, ast } = EsqlQuery.fromSrc(text); + const option = Walker.match(ast, { type: 'option', name: 'as' }); + + expect(errors.length).toBe(1); + expect(option).toBe(undefined); + }); + }); }); diff --git a/src/platform/packages/shared/kbn-esql-ast/src/parser/factories/change_point.ts b/src/platform/packages/shared/kbn-esql-ast/src/parser/factories/change_point.ts index 4b008aec8c03f..735604fa4f529 100644 --- a/src/platform/packages/shared/kbn-esql-ast/src/parser/factories/change_point.ts +++ b/src/platform/packages/shared/kbn-esql-ast/src/parser/factories/change_point.ts @@ -23,7 +23,7 @@ export const createChangePointCommand = ( command.args.push(value); - if (ctx._key) { + if (ctx._key && ctx._key.getText()) { const key = createColumn(ctx._key); const option = Builder.option( {