-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[data views] Remove regex for creating dot notation #193795
Conversation
/ci |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Page load bundle
To update your PR or re-run it, just comment with: cc @mattkime |
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Summary Use basic string and array functions instead of regex to create short dot field names. (cherry picked from commit ab9459c)
## Summary Use basic string and array functions instead of regex to create short dot field names. (cherry picked from commit ab9459c)
💔 Some backports could not be created
Note: Successful backport PRs will be merged automatically after passing CI. Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
## Summary Use basic string and array functions instead of regex to create short dot field names. (cherry picked from commit ab9459c) # Conflicts: # src/plugins/data_views/common/fields/utils.ts
…193808) # Backport This will backport the following commits from `main` to `8.15`: - [[data views] Remove regex for creating dot notation (#193795)](#193795) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Matthew Kime","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-24T00:30:52Z","message":"[data views] Remove regex for creating dot notation (#193795)\n\n## Summary\r\n\r\nUse basic string and array functions instead of regex to create short\r\ndot field names.","sha":"ab9459ca4358451614c3b4fb09380af9841e7a66","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Data Views","release_note:skip","v9.0.0","Team:DataDiscovery","backport:all-open"],"title":"[data views] Remove regex for creating dot notation","number":193795,"url":"https://github.com/elastic/kibana/pull/193795","mergeCommit":{"message":"[data views] Remove regex for creating dot notation (#193795)\n\n## Summary\r\n\r\nUse basic string and array functions instead of regex to create short\r\ndot field names.","sha":"ab9459ca4358451614c3b4fb09380af9841e7a66"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193795","number":193795,"mergeCommit":{"message":"[data views] Remove regex for creating dot notation (#193795)\n\n## Summary\r\n\r\nUse basic string and array functions instead of regex to create short\r\ndot field names.","sha":"ab9459ca4358451614c3b4fb09380af9841e7a66"}}]}] BACKPORT--> Co-authored-by: Matthew Kime <[email protected]>
…193809) # Backport This will backport the following commits from `main` to `8.x`: - [[data views] Remove regex for creating dot notation (#193795)](#193795) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Matthew Kime","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-24T00:30:52Z","message":"[data views] Remove regex for creating dot notation (#193795)\n\n## Summary\r\n\r\nUse basic string and array functions instead of regex to create short\r\ndot field names.","sha":"ab9459ca4358451614c3b4fb09380af9841e7a66","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Data Views","release_note:skip","v9.0.0","Team:DataDiscovery","backport:all-open"],"title":"[data views] Remove regex for creating dot notation","number":193795,"url":"https://github.com/elastic/kibana/pull/193795","mergeCommit":{"message":"[data views] Remove regex for creating dot notation (#193795)\n\n## Summary\r\n\r\nUse basic string and array functions instead of regex to create short\r\ndot field names.","sha":"ab9459ca4358451614c3b4fb09380af9841e7a66"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193795","number":193795,"mergeCommit":{"message":"[data views] Remove regex for creating dot notation (#193795)\n\n## Summary\r\n\r\nUse basic string and array functions instead of regex to create short\r\ndot field names.","sha":"ab9459ca4358451614c3b4fb09380af9841e7a66"}}]}] BACKPORT--> Co-authored-by: Matthew Kime <[email protected]>
/** | ||
* Convert a dot.notated.string into a short | ||
* version (d.n.string) | ||
*/ | ||
export function shortenDottedString(input: string): string { | ||
return typeof input !== 'string' ? input : input.replace(DOT_PREFIX_RE, '$1.'); | ||
if (typeof input === 'string') { | ||
const split = input.split('.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can some parts be empty? For example, can input be something like foo..bar.foo
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, field names can be anything. having two dots in a row would result in f.undefined.b.foo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we address undefined
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI I actually tried ingesting a document like foo..bar.foo
and I got an error:
POST tmp-00001/_doc
{
"asdf..basdf": "bar"
}
// Results in
{
"error": {
"root_cause": [
{
"type": "document_parsing_exception",
"reason": "[1:4] failed to parse: field name cannot contain only whitespace: ['asdf..basdf']"
}
],
"type": "document_parsing_exception",
"reason": "[1:4] failed to parse: field name cannot contain only whitespace: ['asdf..basdf']",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "field name cannot contain only whitespace: ['asdf..basdf']"
}
},
"status": 400
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, I stand corrected. I swear this must be the only limitation on field names. Might be best to talk to an ES engineer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll skip the follow up until someone can produce a field name with two dots in a row
nice, @lukasolson what do you use for this performance check? |
…193811) # Backport This will backport the following commits from `main` to `7.17`: - [[data views] Remove regex for creating dot notation (#193795)](#193795) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Matthew Kime","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-24T00:30:52Z","message":"[data views] Remove regex for creating dot notation (#193795)\n\n## Summary\r\n\r\nUse basic string and array functions instead of regex to create short\r\ndot field names.","sha":"ab9459ca4358451614c3b4fb09380af9841e7a66","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Data Views","release_note:skip","v9.0.0","Team:DataDiscovery","backport:all-open"],"number":193795,"url":"https://github.com/elastic/kibana/pull/193795","mergeCommit":{"message":"[data views] Remove regex for creating dot notation (#193795)\n\n## Summary\r\n\r\nUse basic string and array functions instead of regex to create short\r\ndot field names.","sha":"ab9459ca4358451614c3b4fb09380af9841e7a66"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193795","number":193795,"mergeCommit":{"message":"[data views] Remove regex for creating dot notation (#193795)\n\n## Summary\r\n\r\nUse basic string and array functions instead of regex to create short\r\ndot field names.","sha":"ab9459ca4358451614c3b4fb09380af9841e7a66"}},{"url":"https://github.com/elastic/kibana/pull/193808","number":193808,"branch":"8.15","state":"OPEN"},{"url":"https://github.com/elastic/kibana/pull/193809","number":193809,"branch":"8.x","state":"OPEN"}]}] BACKPORT-->
https://jsbench.me/ - did a comparison with some simple strings as well as fairly long ones |
Summary
Use basic string and array functions instead of regex to create short dot field names.