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 @@ -452,10 +452,6 @@ export interface ValidationErrors {
message: string;
type: {};
};
forkTooFewBranches: {
message: string;
type: {};
};
forkNotAllowedWithSubqueries: {
message: string;
type: {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,6 @@ Expected one of:
}),
type: 'error',
};
case 'forkTooFewBranches':
return {
message: i18n.translate('kbn-esql-language.esql.validation.forkTooFewBranches', {
defaultMessage: '[FORK] Must include at least two branches.',
}),
type: 'error',
};
case 'forkNotAllowedWithSubqueries':
return {
message: i18n.translate('kbn-esql-language.esql.validation.forkNotAllowedWithSubqueries', {
Expand Down Expand Up @@ -750,9 +743,6 @@ export const errors = {
forkTooManyBranches: (command: ESQLAstAllCommands): ESQLMessage =>
errors.byId('forkTooManyBranches', command.location, {}),

forkTooFewBranches: (command: ESQLAstAllCommands): ESQLMessage =>
errors.byId('forkTooFewBranches', command.location, {}),

forkNotAllowedWithSubqueries: (command: ESQLAstAllCommands): ESQLMessage =>
errors.byId('forkNotAllowedWithSubqueries', command.location, {}),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('FORK Autocomplete', () => {
});

test('suggests pipe and new branch after complete branch', async () => {
await forkExpectSuggestions('FROM a | FORK (LIMIT 100) ', ['($0)']);
await forkExpectSuggestions('FROM a | FORK (LIMIT 100) ', ['($0)', '| ']);
await forkExpectSuggestions('FROM a | FORK (LIMIT 100) (SORT keywordField ASC) ', [
'($0)',
'| ',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function autocomplete(

if (!withinActiveBranch && /\)\s+$/i.test(innerText)) {
const suggestions = [newBranchSuggestion];
if (forkCommand.args.length > 1) {
if (forkCommand.args.length > 0) {
suggestions.push(pipeCompleteItem);
}
return suggestions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ describe('FORK Validation', () => {
);
});

test('requires at least two branches', () => {
test('Allows FORK with one branch', () => {
forkExpectErrors(
`FROM index
| FORK
(WHERE keywordField != "")`,
[`[FORK] Must include at least two branches.`]
[]
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import type { ICommandContext, ICommandCallbacks } from '../types';
import { validateCommandArguments } from '../../definitions/utils/validation';
import { errors } from '../../definitions/utils';

const MIN_BRANCHES = 2;
const MAX_BRANCHES = 8;

export const validate = (
Expand All @@ -29,10 +28,6 @@ export const validate = (
const forkCommand = command as ESQLAstForkCommand;
const messages: ESQLMessage[] = [];

if (forkCommand.args.length < MIN_BRANCHES) {
messages.push(errors.forkTooFewBranches(forkCommand));
}

if (forkCommand.args.length > MAX_BRANCHES) {
messages.push(errors.forkTooManyBranches(forkCommand));
}
Expand Down
5 changes: 0 additions & 5 deletions src/platform/plugins/shared/esql/ADD_COMMAND_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@ export const validate = (
): ESQLMessage[] => {
const messages: ESQLMessage[] = [];

// custom check specific to FORK
if (command.args.length < MIN_BRANCHES) {
messages.push(errors.forkTooFewBranches(command));
}

// custom check specific to FORK
if (command.args.length > MAX_BRANCHES) {
messages.push(errors.forkTooManyBranches(command));
Expand Down
Loading