Skip to content

Commit

Permalink
[8.14] [ES|QL] remove quoted index name support (#182994) (#183006)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.14`:
- [[ES|QL] remove quoted index name support
(#182994)](#182994)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Drew
Tate","email":"drew.tate@elastic.co"},"sourceCommit":{"committedDate":"2024-05-09T03:51:50Z","message":"[ES|QL]
remove quoted index name support (#182994)\n\n## Summary\r\n\r\nThe
Kibana version
of\r\nhttps://github.com/elastic/elasticsearch/pull/108431\r\n\r\nRemoves
support for quoted index names. \r\n\r\nValid:\r\n`from
my_index`\r\n\r\nInvalid\r\n`from \"my_index\"`\r\n\r\n<img
width=\"514\" alt=\"Screenshot 2024-05-08 at 2 10
24 PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/315764/f76f9128-cc13-41df-b885-b1ec30fe7ca3\">\r\n<img
width=\"711\" alt=\"Screenshot 2024-05-08 at 2 10
17 PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/315764/651c0480-ddcd-4f2b-ba05-862b3ca8a402\">","sha":"34502a9253a9505889ec2a923cc0a08a624868de","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","Feature:ES|QL","v8.14.0","Team:ESQL","v8.15.0"],"number":182994,"url":"https://github.com/elastic/kibana/pull/182994","mergeCommit":{"message":"[ES|QL]
remove quoted index name support (#182994)\n\n## Summary\r\n\r\nThe
Kibana version
of\r\nhttps://github.com/elastic/elasticsearch/pull/108431\r\n\r\nRemoves
support for quoted index names. \r\n\r\nValid:\r\n`from
my_index`\r\n\r\nInvalid\r\n`from \"my_index\"`\r\n\r\n<img
width=\"514\" alt=\"Screenshot 2024-05-08 at 2 10
24 PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/315764/f76f9128-cc13-41df-b885-b1ec30fe7ca3\">\r\n<img
width=\"711\" alt=\"Screenshot 2024-05-08 at 2 10
17 PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/315764/651c0480-ddcd-4f2b-ba05-862b3ca8a402\">","sha":"34502a9253a9505889ec2a923cc0a08a624868de"}},"sourceBranch":"main","suggestedTargetBranches":["8.14"],"targetPullRequestStates":[{"branch":"8.14","label":"v8.14.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.15.0","labelRegex":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/182994","number":182994,"mergeCommit":{"message":"[ES|QL]
remove quoted index name support (#182994)\n\n## Summary\r\n\r\nThe
Kibana version
of\r\nhttps://github.com/elastic/elasticsearch/pull/108431\r\n\r\nRemoves
support for quoted index names. \r\n\r\nValid:\r\n`from
my_index`\r\n\r\nInvalid\r\n`from \"my_index\"`\r\n\r\n<img
width=\"514\" alt=\"Screenshot 2024-05-08 at 2 10
24 PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/315764/f76f9128-cc13-41df-b885-b1ec30fe7ca3\">\r\n<img
width=\"711\" alt=\"Screenshot 2024-05-08 at 2 10
17 PM\"\r\nsrc=\"https://github.com/elastic/kibana/assets/315764/651c0480-ddcd-4f2b-ba05-862b3ca8a402\">","sha":"34502a9253a9505889ec2a923cc0a08a624868de"}}]}]
BACKPORT-->
  • Loading branch information
drewdaemon authored May 9, 2024
1 parent 9ea601f commit a14ee25
Show file tree
Hide file tree
Showing 10 changed files with 1,219 additions and 2,609 deletions.
4 changes: 0 additions & 4 deletions packages/kbn-esql-ast/src/antlr/esql_lexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,6 @@ FROM_UNQUOTED_IDENTIFIER
: FROM_UNQUOTED_IDENTIFIER_PART+
;

FROM_QUOTED_IDENTIFIER
: QUOTED_IDENTIFIER -> type(QUOTED_IDENTIFIER)
;

FROM_LINE_COMMENT
: LINE_COMMENT -> channel(HIDDEN)
;
Expand Down
3 changes: 1 addition & 2 deletions packages/kbn-esql-ast/src/antlr/esql_lexer.interp

Large diffs are not rendered by default.

791 changes: 394 additions & 397 deletions packages/kbn-esql-ast/src/antlr/esql_lexer.ts

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion packages/kbn-esql-ast/src/antlr/esql_parser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ fromCommand

fromIdentifier
: FROM_UNQUOTED_IDENTIFIER
| QUOTED_IDENTIFIER
;

fromOptions
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-esql-ast/src/antlr/esql_parser.interp

Large diffs are not rendered by default.

275 changes: 132 additions & 143 deletions packages/kbn-esql-ast/src/antlr/esql_parser.ts

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions packages/kbn-esql-ast/src/ast_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ export function computeLocationExtends(fn: ESQLFunction) {

/* SCRIPT_MARKER_START */
function getQuotedText(ctx: ParserRuleContext) {
return [67 /* esql_parser.QUOTED_IDENTIFIER */]
return [27 /* esql_parser.QUOTED_STRING */, 67 /* esql_parser.QUOTED_IDENTIFIER */]
.map((keyCode) => ctx.getToken(keyCode, 0))
.filter(nonNullable)[0];
}

function getUnquotedText(ctx: ParserRuleContext) {
return [66 /* esql_parser.UNQUOTED_IDENTIFIER */, 72 /* esql_parser.FROM_UNQUOTED_IDENTIFIER */]
return [66 /* esql_parser.UNQUOTED_IDENTIFIER */, 73 /* esql_parser.FROM_UNQUOTED_IDENTIFIER */]
.map((keyCode) => ctx.getToken(keyCode, 0))
.filter(nonNullable)[0];
}
Expand All @@ -238,11 +238,13 @@ function safeBackticksRemoval(text: string | undefined) {
}

export function sanitizeIdentifierString(ctx: ParserRuleContext) {
return (
const result =
getUnquotedText(ctx)?.getText() ||
safeBackticksRemoval(getQuotedText(ctx)?.getText()) ||
safeBackticksRemoval(ctx.getText()) // for some reason some quoted text is not detected correctly by the parser
);
safeBackticksRemoval(ctx.getText()); // for some reason some quoted text is not detected correctly by the parser

// TODO - understand why <missing null> is now returned as the match text for the FROM command
return result === '<missing null>' ? '' : result;
}

export function wrapIdentifierAsArray<T extends ParserRuleContext>(identifierCtx: T | T[]): T[] {
Expand Down
6 changes: 3 additions & 3 deletions packages/kbn-esql-ast/src/ast_walker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ import type {
} from './types';

export function collectAllSourceIdentifiers(ctx: FromCommandContext): ESQLAstItem[] {
return ctx
.getTypedRuleContexts(FromIdentifierContext)
.map((sourceCtx) => createSource(sourceCtx));
const fromContexts = ctx.getTypedRuleContexts(FromIdentifierContext);

return fromContexts.map((sourceCtx) => createSource(sourceCtx));
}

function extractIdentifiers(
Expand Down
Loading

0 comments on commit a14ee25

Please sign in to comment.