Skip to content

Commit 98ab523

Browse files
[8.19] [ES|QL] Fixes rename wrong validation for asterisc in name (#219832) (#220194)
# Backport This will backport the following commits from `main` to `8.19`: - [[ES|QL] Fixes rename wrong validation for asterisc in name (#219832)](#219832) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Stratoula Kalafateli","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-05-06T06:48:28Z","message":"[ES|QL] Fixes rename wrong validation for asterisc in name (#219832)\n\n## Summary\n\nRemoves the wildcard validation to fix wrong validation like that:\n\n<img width=\"844\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/c71ee9a9-539a-40a4-b467-2bedf0111ae5\"\n/>\n\n\nThis scenario\n\n```\nFROM logst* | RENAME agent* AS meow \n```\n\nfails already so we are ok I think\n\n### Checklist\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"f5afb22941f6008db2f22c1b6fda781e6f9c7e4c","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Feature:ES|QL","Team:ESQL","backport:version","v9.1.0","v8.19.0"],"title":"[ES|QL] Fixes rename wrong validation for asterisc in name","number":219832,"url":"https://github.com/elastic/kibana/pull/219832","mergeCommit":{"message":"[ES|QL] Fixes rename wrong validation for asterisc in name (#219832)\n\n## Summary\n\nRemoves the wildcard validation to fix wrong validation like that:\n\n<img width=\"844\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/c71ee9a9-539a-40a4-b467-2bedf0111ae5\"\n/>\n\n\nThis scenario\n\n```\nFROM logst* | RENAME agent* AS meow \n```\n\nfails already so we are ok I think\n\n### Checklist\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"f5afb22941f6008db2f22c1b6fda781e6f9c7e4c"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219832","number":219832,"mergeCommit":{"message":"[ES|QL] Fixes rename wrong validation for asterisc in name (#219832)\n\n## Summary\n\nRemoves the wildcard validation to fix wrong validation like that:\n\n<img width=\"844\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/c71ee9a9-539a-40a4-b467-2bedf0111ae5\"\n/>\n\n\nThis scenario\n\n```\nFROM logst* | RENAME agent* AS meow \n```\n\nfails already so we are ok I think\n\n### Checklist\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"f5afb22941f6008db2f22c1b6fda781e6f9c7e4c"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Stratoula Kalafateli <[email protected]>
1 parent e9e9027 commit 98ab523

File tree

3 files changed

+4
-45
lines changed

3 files changed

+4
-45
lines changed

src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/commands.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import {
1515
type ESQLCommand,
1616
type ESQLFunction,
1717
type ESQLMessage,
18-
type ESQLAstRenameExpression,
19-
Walker,
2018
} from '@kbn/esql-ast';
2119
import { i18n } from '@kbn/i18n';
2220
import {
@@ -301,35 +299,6 @@ export const commandDefinitions: Array<CommandDefinition<any>> = [
301299
declaration: 'RENAME old_name1 AS new_name1[, ..., old_nameN AS new_nameN]',
302300
examples: ['… | RENAME old AS new', '… | RENAME old AS new, a AS b'],
303301
suggest: suggestForRename,
304-
validate: (command: ESQLCommand<'rename'>) => {
305-
const messages: ESQLMessage[] = [];
306-
307-
const renameExpressions = Walker.findAll(command, (node) => {
308-
return node.type === 'option' && node.name === 'as';
309-
}) as ESQLAstRenameExpression[];
310-
311-
for (const expression of renameExpressions) {
312-
const [column] = expression.args;
313-
if (!isColumnItem(column)) {
314-
continue;
315-
}
316-
317-
if (hasWildcard(column.name)) {
318-
messages.push(
319-
getMessageFromId({
320-
messageId: 'wildcardNotSupportedForCommand',
321-
values: {
322-
command: 'RENAME',
323-
value: column.name,
324-
},
325-
locations: column.location,
326-
})
327-
);
328-
}
329-
}
330-
331-
return messages;
332-
},
333302
fieldsSuggestionsAfter: fieldsSuggestionsAfterRename,
334303
},
335304
{

src/platform/packages/shared/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,22 +2635,17 @@
26352635
{
26362636
"query": "from a_index | rename key* as keywords",
26372637
"error": [
2638-
"Using wildcards (*) in RENAME is not allowed [key*]",
26392638
"Unknown column [keywords]"
26402639
],
26412640
"warning": []
26422641
},
26432642
{
2644-
"query": "from a_index | rename s* as strings",
2645-
"error": [
2646-
"Using wildcards (*) in RENAME is not allowed [s*]",
2647-
"Unknown column [s*]",
2648-
"Unknown column [strings]"
2649-
],
2643+
"query": "row a = 10 | rename a as `this``is fine`",
2644+
"error": [],
26502645
"warning": []
26512646
},
26522647
{
2653-
"query": "row a = 10 | rename a as `this``is fine`",
2648+
"query": "ROW `C*OUNT` = 5 | RENAME `C*OUNT` AS meow",
26542649
"error": [],
26552650
"warning": []
26562651
},

src/platform/packages/shared/kbn-esql-validation-autocomplete/src/validation/validation.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -676,15 +676,10 @@ describe('validation logic', () => {
676676
"SyntaxError: mismatched input '<EOF>' expecting {'?', '??', NAMED_OR_POSITIONAL_PARAM, NAMED_OR_POSITIONAL_DOUBLE_PARAMS, ID_PATTERN}",
677677
]);
678678
testErrorsAndWarnings('from a_index | rename key* as keywords', [
679-
'Using wildcards (*) in RENAME is not allowed [key*]',
680679
'Unknown column [keywords]',
681680
]);
682-
testErrorsAndWarnings('from a_index | rename s* as strings', [
683-
'Using wildcards (*) in RENAME is not allowed [s*]',
684-
'Unknown column [s*]',
685-
'Unknown column [strings]',
686-
]);
687681
testErrorsAndWarnings('row a = 10 | rename a as `this``is fine`', []);
682+
testErrorsAndWarnings('ROW `C*OUNT` = 5 | RENAME `C*OUNT` AS meow', []);
688683
testErrorsAndWarnings('row a = 10 | rename a as this is fine', [
689684
"SyntaxError: mismatched input 'is' expecting <EOF>",
690685
]);

0 commit comments

Comments
 (0)