-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[ML]Fix latest transforms disregarding updates when sort and sync fields are non-monotonic #142856
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f485c3d
Fix Latest Transform Non-Monotonic Sort Issue
valeriy42 cac0305
Update docs/changelog/142856.yaml
valeriy42 30e0611
update comments
valeriy42 642acda
Merge branch 'fix/is-90643' of https://github.com/valeriy42/elasticse…
valeriy42 e750df0
fix html charecter
valeriy42 3e08e0d
Merge branch 'main' into fix/is-90643
valeriy42 bb87bde
[CI] Auto commit changes from spotless
b789e7f
review comments
valeriy42 08bb63b
Merge branch 'main' into fix/is-90643
valeriy42 c7696a5
fix unit test to match the pagination optimization
valeriy42 5fcb1dc
Merge branch 'fix/is-90643' of https://github.com/valeriy42/elasticse…
valeriy42 bd319c2
remove optimization
valeriy42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| area: Transform | ||
| issues: | ||
| - 90643 | ||
| pr: 142856 | ||
| summary: "[ML]Fix latest transforms disregarding updates when sort and sync fields\ | ||
| \ are non-monotonic" | ||
| type: bug |
121 changes: 121 additions & 0 deletions
121
x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/transform/transforms_latest.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| setup: | ||
| - do: | ||
| indices.create: | ||
| index: latest-test-data | ||
| body: | ||
| mappings: | ||
| properties: | ||
| order_id: | ||
| type: keyword | ||
| region: | ||
| type: keyword | ||
| status: | ||
| type: keyword | ||
| updated_at: | ||
| type: date | ||
| event_ingested: | ||
| type: date | ||
|
|
||
| - do: | ||
| bulk: | ||
| index: latest-test-data | ||
| refresh: true | ||
| body: | ||
| - '{"index": {}}' | ||
| - '{"order_id": "order-1", "region": "US", "status": "accepted", "updated_at": "2024-01-01T00:00:05Z", "event_ingested": "2024-01-01T00:00:10Z"}' | ||
| - '{"index": {}}' | ||
| - '{"order_id": "order-1", "region": "US", "status": "pending", "updated_at": "2024-01-01T00:00:03Z", "event_ingested": "2024-01-01T00:00:20Z"}' | ||
| - '{"index": {}}' | ||
| - '{"order_id": "order-2", "region": "EU", "status": "shipped", "updated_at": "2024-01-01T00:00:08Z", "event_ingested": "2024-01-01T00:00:15Z"}' | ||
| - '{"index": {}}' | ||
| - '{"order_id": "order-2", "region": "EU", "status": "processing", "updated_at": "2024-01-01T00:00:01Z", "event_ingested": "2024-01-01T00:00:25Z"}' | ||
| - '{"index": {}}' | ||
| - '{"order_id": "order-3", "region": "US", "status": "delivered", "updated_at": "2024-01-01T00:00:02Z", "event_ingested": "2024-01-01T00:00:05Z"}' | ||
|
|
||
| --- | ||
| teardown: | ||
| - do: | ||
| indices.delete: | ||
| index: latest-test-data | ||
| ignore: 404 | ||
|
|
||
| --- | ||
| "Test latest preview picks correct document when sort and sync fields are non-monotonic": | ||
| - do: | ||
| transform.preview_transform: | ||
| body: > | ||
| { | ||
| "source": { "index": "latest-test-data" }, | ||
| "latest": { | ||
| "unique_key": [ "order_id" ], | ||
| "sort": "updated_at" | ||
| } | ||
| } | ||
|
|
||
| - length: { preview: 3 } | ||
|
|
||
| # Composite agg returns results sorted by unique_key lexicographically. | ||
| # order-1 should pick status=accepted (updated_at T+5s) over status=pending (updated_at T+3s) | ||
| # even though pending has a later event_ingested. | ||
| - match: { preview.0.order_id: "order-1" } | ||
| - match: { preview.0.status: "accepted" } | ||
| - match: { preview.1.order_id: "order-2" } | ||
| - match: { preview.1.status: "shipped" } | ||
| - match: { preview.2.order_id: "order-3" } | ||
| - match: { preview.2.status: "delivered" } | ||
|
|
||
| --- | ||
| "Test latest preview with multi-field unique key": | ||
| - do: | ||
| transform.preview_transform: | ||
| body: > | ||
| { | ||
| "source": { "index": "latest-test-data" }, | ||
| "latest": { | ||
| "unique_key": [ "order_id", "region" ], | ||
| "sort": "updated_at" | ||
| } | ||
| } | ||
|
|
||
| - length: { preview: 3 } | ||
|
|
||
| # With multi-field unique key [order_id, region], each combination should pick highest updated_at. | ||
| # Results sorted lexicographically by [order_id, region]. | ||
| - match: { preview.0.order_id: "order-1" } | ||
| - match: { preview.0.region: "US" } | ||
| - match: { preview.0.status: "accepted" } | ||
| - match: { preview.1.order_id: "order-2" } | ||
| - match: { preview.1.region: "EU" } | ||
| - match: { preview.1.status: "shipped" } | ||
| - match: { preview.2.order_id: "order-3" } | ||
| - match: { preview.2.region: "US" } | ||
| - match: { preview.2.status: "delivered" } | ||
|
|
||
| --- | ||
| "Test latest preview includes document IDs": | ||
| - do: | ||
| transform.preview_transform: | ||
| body: > | ||
| { | ||
| "source": { "index": "latest-test-data" }, | ||
| "latest": { | ||
| "unique_key": [ "order_id" ], | ||
| "sort": "updated_at" | ||
| } | ||
| } | ||
|
|
||
| - length: { preview: 3 } | ||
|
|
||
| # Verify all expected fields are present with correct values. | ||
| - match: { preview.0.order_id: "order-1" } | ||
| - match: { preview.0.region: "US" } | ||
| - match: { preview.0.status: "accepted" } | ||
| - is_true: preview.0.updated_at | ||
| - match: { preview.1.order_id: "order-2" } | ||
| - match: { preview.1.region: "EU" } | ||
| - match: { preview.1.status: "shipped" } | ||
| - is_true: preview.1.updated_at | ||
| - match: { preview.2.order_id: "order-3" } | ||
| - match: { preview.2.region: "US" } | ||
| - match: { preview.2.status: "delivered" } | ||
| - is_true: preview.2.updated_at | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.