diff --git a/packages/kbn-esql-validation-autocomplete/src/validation/__tests__/test_suites/validation.command.from.ts b/packages/kbn-esql-validation-autocomplete/src/validation/__tests__/test_suites/validation.command.from.ts index e3589bb8da643..3da63848168a3 100644 --- a/packages/kbn-esql-validation-autocomplete/src/validation/__tests__/test_suites/validation.command.from.ts +++ b/packages/kbn-esql-validation-autocomplete/src/validation/__tests__/test_suites/validation.command.from.ts @@ -56,12 +56,6 @@ export const validationFromCommandTestSuite = (setup: helpers.Setup) => { await expectErrors('fRoM in*ex', []); await expectErrors('fRoM ind*ex', []); await expectErrors('fRoM *,-.*', []); - await expectErrors('fRoM remote-*:indexes*', ['Unknown index [remote-*:indexes*]']); - await expectErrors('fRoM remote-*:indexes', ['Unknown index [remote-*:indexes]']); - await expectErrors('fRoM remote-ccs:indexes', ['Unknown index [remote-ccs:indexes]']); - await expectErrors('fRoM a_index, remote-ccs:indexes', [ - 'Unknown index [remote-ccs:indexes]', - ]); await expectErrors('fRoM .secret_index', []); await expectErrors('from my-index', []); }); @@ -151,16 +145,6 @@ export const validationFromCommandTestSuite = (setup: helpers.Setup) => { [], addBracketsWarning() ); - await expectErrors( - `from remote-ccs:indexes ${setWrapping('METADATA _id')}`, - ['Unknown index [remote-ccs:indexes]'], - addBracketsWarning() - ); - await expectErrors( - `from *:indexes ${setWrapping('METADATA _id')}`, - ['Unknown index [*:indexes]'], - addBracketsWarning() - ); }); test('validates fields', async () => { diff --git a/packages/kbn-esql-validation-autocomplete/src/validation/__tests__/validation.ccs.test.ts b/packages/kbn-esql-validation-autocomplete/src/validation/__tests__/validation.ccs.test.ts new file mode 100644 index 0000000000000..5cdb83be618d1 --- /dev/null +++ b/packages/kbn-esql-validation-autocomplete/src/validation/__tests__/validation.ccs.test.ts @@ -0,0 +1,57 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ +import { setup } from './helpers'; + +describe('validation', () => { + describe('from command', () => { + describe('FROM [ METADATA ]', () => { + describe('... ...', () => { + test('display errors on unknown indices', async () => { + const { expectErrors } = await setup(); + await expectErrors('fRoM remote-*:indexes*', ['Unknown index [remote-*:indexes*]']); + await expectErrors('fRoM remote-*:indexes', ['Unknown index [remote-*:indexes]']); + await expectErrors('fRoM remote-ccs:indexes', ['Unknown index [remote-ccs:indexes]']); + await expectErrors('fRoM a_index, remote-ccs:indexes', [ + 'Unknown index [remote-ccs:indexes]', + ]); + }); + }); + + describe('... METADATA ', () => { + for (const isWrapped of [true, false]) { + function setWrapping(option: string) { + return isWrapped ? `[${option}]` : option; + } + + function addBracketsWarning() { + return isWrapped + ? ["Square brackets '[]' need to be removed from FROM METADATA declaration"] + : []; + } + + describe(`wrapped = ${isWrapped}`, () => { + test('no errors on correct usage, waning on square brackets', async () => { + const { expectErrors } = await setup(); + await expectErrors( + `from remote-ccs:indexes ${setWrapping('METADATA _id')}`, + ['Unknown index [remote-ccs:indexes]'], + addBracketsWarning() + ); + await expectErrors( + `from *:indexes ${setWrapping('METADATA _id')}`, + ['Unknown index [*:indexes]'], + addBracketsWarning() + ); + }); + }); + } + }); + }); + }); +}); diff --git a/packages/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json b/packages/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json index 1eb861168a13a..43a42f0270b74 100644 --- a/packages/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json +++ b/packages/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json @@ -9834,26 +9834,6 @@ "error": [], "warning": [] }, - { - "query": "fRoM remote-*:indexes*", - "error": [], - "warning": [] - }, - { - "query": "fRoM remote-*:indexes", - "error": [], - "warning": [] - }, - { - "query": "fRoM remote-ccs:indexes", - "error": [], - "warning": [] - }, - { - "query": "fRoM a_index, remote-ccs:indexes", - "error": [], - "warning": [] - }, { "query": "fRoM .secret_index", "error": [], @@ -9986,20 +9966,6 @@ "Square brackets '[]' need to be removed from FROM METADATA declaration" ] }, - { - "query": "from remote-ccs:indexes [METADATA _id]", - "error": [], - "warning": [ - "Square brackets '[]' need to be removed from FROM METADATA declaration" - ] - }, - { - "query": "from *:indexes [METADATA _id]", - "error": [], - "warning": [ - "Square brackets '[]' need to be removed from FROM METADATA declaration" - ] - }, { "query": "from index [METADATA _id, _source2]", "error": [ @@ -10038,16 +10004,6 @@ "error": [], "warning": [] }, - { - "query": "from remote-ccs:indexes METADATA _id", - "error": [], - "warning": [] - }, - { - "query": "from *:indexes METADATA _id", - "error": [], - "warning": [] - }, { "query": "from index METADATA _id, _source2", "error": [