Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -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);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const createChangePointCommand = (

command.args.push(value);

if (ctx._key) {
if (ctx._key && ctx._key.getText()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ do we need the same check with getText for ctx._targetType && ctx._targetPvalue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. If it was only ctx._targetType we would need the check but because it is ctx._targetType && ctx._targetPvalue we don't need it. ANTLR does not generate an empty identifier for pvalue, only for target.

const key = createColumn(ctx._key);
const option = Builder.option(
{
Expand Down