Skip to content

Commit

Permalink
[8.x] [ES|QL] Create validation errors for unknown parameters (#197334)…
Browse files Browse the repository at this point in the history
… (#197452)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ES|QL] Create validation errors for unknown parameters
(#197334)](#197334)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Drew
Tate","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-23T13:49:38Z","message":"[ES|QL]
Create validation errors for unknown parameters (#197334)\n\n##
Summary\r\n\r\nFollow-up from
https://github.com/elastic/kibana/pull/195989.\r\n\r\nWe discussed as a
team and decided to show validation errors when an\r\nunknown variable
is used as an argument to subsequent
functions.\r\n\r\n**Before**\r\n<img width=\"589\" alt=\"Screenshot
2024-10-22 at 1 41
08 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/872d3302-ddfe-415f-9c98-e2c682344189\">\r\n\r\n\r\n**After**\r\n<img
width=\"570\" alt=\"Screenshot 2024-10-22 at 1 41
29 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/b7e29c2d-ee40-4730-b1ab-43d95dfd264c\">","sha":"e1c0cef15dd7f771a621db0230bf4cddcf10815b","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Feature:ES|QL","Team:ESQL","v8.16.0","backport:version","v8.17.0"],"title":"[ES|QL]
Create validation errors for unknown
parameters","number":197334,"url":"https://github.com/elastic/kibana/pull/197334","mergeCommit":{"message":"[ES|QL]
Create validation errors for unknown parameters (#197334)\n\n##
Summary\r\n\r\nFollow-up from
https://github.com/elastic/kibana/pull/195989.\r\n\r\nWe discussed as a
team and decided to show validation errors when an\r\nunknown variable
is used as an argument to subsequent
functions.\r\n\r\n**Before**\r\n<img width=\"589\" alt=\"Screenshot
2024-10-22 at 1 41
08 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/872d3302-ddfe-415f-9c98-e2c682344189\">\r\n\r\n\r\n**After**\r\n<img
width=\"570\" alt=\"Screenshot 2024-10-22 at 1 41
29 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/b7e29c2d-ee40-4730-b1ab-43d95dfd264c\">","sha":"e1c0cef15dd7f771a621db0230bf4cddcf10815b"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197334","number":197334,"mergeCommit":{"message":"[ES|QL]
Create validation errors for unknown parameters (#197334)\n\n##
Summary\r\n\r\nFollow-up from
https://github.com/elastic/kibana/pull/195989.\r\n\r\nWe discussed as a
team and decided to show validation errors when an\r\nunknown variable
is used as an argument to subsequent
functions.\r\n\r\n**Before**\r\n<img width=\"589\" alt=\"Screenshot
2024-10-22 at 1 41
08 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/872d3302-ddfe-415f-9c98-e2c682344189\">\r\n\r\n\r\n**After**\r\n<img
width=\"570\" alt=\"Screenshot 2024-10-22 at 1 41
29 PM\"\r\nsrc=\"https://github.com/user-attachments/assets/b7e29c2d-ee40-4730-b1ab-43d95dfd264c\">","sha":"e1c0cef15dd7f771a621db0230bf4cddcf10815b"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Drew Tate <[email protected]>
  • Loading branch information
kibanamachine and drewdaemon authored Oct 23, 2024
1 parent a4da28c commit fd81ac4
Show file tree
Hide file tree
Showing 2 changed files with 226 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ export function checkFunctionArgMatchesDefinition(
const wrappedTypes: Array<(typeof validHit)['type']> = Array.isArray(validHit.type)
? validHit.type
: [validHit.type];
return wrappedTypes.some((ct) => ct === argType || ct === 'null' || ct === 'unknown');
return wrappedTypes.some((ct) => ct === argType || ct === 'null');
}
if (arg.type === 'inlineCast') {
const lowerArgType = argType?.toLowerCase();
Expand Down
Loading

0 comments on commit fd81ac4

Please sign in to comment.