Skip to content

Commit

Permalink
remove ppl agg func snippets and update ppl field name test
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Sebastian <[email protected]>
  • Loading branch information
paulstn committed Jan 17, 2025
1 parent 5117119 commit 25d0ef5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
10 changes: 1 addition & 9 deletions src/plugins/data/public/antlr/opensearch_ppl/code_completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,10 @@ export const getSuggestions = async ({
...PPL_AGGREGATE_FUNCTIONS.map((af) => ({
text: `${af}()`,
type: monaco.languages.CompletionItemKind.Function,
insertText: af + '(${1:expr}) ',
insertText: af + ' ',
detail: SuggestionItemDetailsTags.AggregateFunction,
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
}))
);
// separately include count as there will be nothing within the parens
finalSuggestions.push({
text: `count()`,
type: monaco.languages.CompletionItemKind.Function,
insertText: 'count() ',
detail: SuggestionItemDetailsTags.AggregateFunction,
});
}

if (suggestions.suggestSourcesOrTables) {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/public/antlr/opensearch_ppl/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { OpenSearchPPLParser } from './.generated/OpenSearchPPLParser';

export const PPL_AGGREGATE_FUNCTIONS = [
'avg',
'count',
'sum',
'min',
'max',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ describe('processVisitedRules', () => {
const mockRules = new Map();
mockRules.set(OpenSearchPPLParser.RULE_statsFunctionName, {});
mockRules.set(OpenSearchPPLParser.RULE_fieldExpression, {});
const tokenStream = createTokenStream([1]);
const tokenStream = createTokenStream([
{ type: 1, text: 'SPACE' },
{ type: 1, text: 'SPACE' },
]);

const result = processVisitedRules(mockRules, 2, tokenStream);
expect(result.suggestAggregateFunctions).toBeDefined();
Expand Down

0 comments on commit 25d0ef5

Please sign in to comment.