Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ES|QL] Open bracket parsing bug #196241

Merged
merged 8 commits into from
Oct 18, 2024
Merged
16 changes: 16 additions & 0 deletions packages/kbn-esql-ast/src/parser/__tests__/from.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,21 @@ describe('FROM', () => {

expect(errors.length > 0).toBe(true);
});

it('when open square bracket "[" is entered', () => {
const text = 'FROM kibana_sample_data_logs [';
const { errors } = parse(text);

expect(errors.length > 0).toBe(true);
expect(errors[0].message.toLowerCase().includes('metadata')).toBe(true);
});

it('when close square bracket "]" is entered', () => {
const text = 'FROM kibana_sample_data_logs []';
const { errors } = parse(text);

expect(errors.length > 0).toBe(true);
expect(errors[0].message.toLowerCase().includes('metadata')).toBe(true);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class ESQLAstBuilderListener implements ESQLParserListener {
const metadataContext = ctx.metadata();
const metadataContent =
metadataContext?.deprecated_metadata()?.metadataOption() || metadataContext?.metadataOption();
if (metadataContent) {
if (metadataContent && metadataContent.METADATA()) {
const option = createOption(
metadataContent.METADATA().getText().toLowerCase(),
metadataContent
Expand Down