Repository navigation
fix: Prevent windowing on multi-key sort states w/o leading timestamp #3907
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
Open
pulpdrew
wants to merge
1
commit into
main
Choose a base branch
from
drew/fix-3905
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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,6 @@ | ||
| --- | ||
| '@hyperdx/common-utils': patch | ||
| '@hyperdx/app': patch | ||
| --- | ||
|
|
||
| fix: Don't bucket search queries by time when the leading sort key isn't the timestamp |
6 changes: 4 additions & 2 deletions
6
packages/app/src/components/SearchResultsToolbar/sortClause.ts
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
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
56 changes: 56 additions & 0 deletions
56
packages/app/tests/e2e/features/search/multi-key-sort-windowing.spec.ts
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,56 @@ | ||
| import { SearchPage } from '../../page-objects/SearchPage'; | ||
| import { expect, test } from '../../utils/base-test'; | ||
| import { DEFAULT_TRACES_SOURCE_NAME } from '../../utils/constants'; | ||
|
|
||
| // Bounds are bind parameters: the SQL names them and the URL carries values. | ||
| const TIME_RANGE_PREDICATE = | ||
| /Timestamp\s*>=\s*fromUnixTimestamp64Milli\(\{(\w+):Int64\}\)\s*AND\s*Timestamp\s*<=\s*fromUnixTimestamp64Milli\(\{(\w+):Int64\}\)/; | ||
| const RANGE_MS = 24 * 60 * 60 * 1000; | ||
|
|
||
| test.describe( | ||
| 'Search with a multi-key Order By', | ||
| { tag: ['@search', '@full-stack'] }, | ||
| () => { | ||
| test('does not bucket by time window when the leading sort key is not the timestamp', async ({ | ||
| page, | ||
| }) => { | ||
| test.setTimeout(60000); | ||
| const searchPage = new SearchPage(page); | ||
|
|
||
| const rowQuerySpansMs: number[] = []; | ||
| // query_id marks ClickHouse queries from the app. | ||
| page.on('request', request => { | ||
| const url = new URL(request.url()); | ||
| const body = request.postData() ?? ''; | ||
| if ( | ||
| url.searchParams.has('query_id') && | ||
| /ORDER BY\s+Duration DESC,\s*Timestamp DESC\s+LIMIT/.test(body) | ||
| ) { | ||
| const range = body.match(TIME_RANGE_PREDICATE); | ||
| if (range) { | ||
| const start = Number(url.searchParams.get(`param_${range[1]}`)); | ||
| const end = Number(url.searchParams.get(`param_${range[2]}`)); | ||
| rowQuerySpansMs.push(end - start); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| const to = Date.now(); | ||
| const from = to - RANGE_MS; | ||
| await page.goto( | ||
| `/search?isLive=false&from=${from}&to=${to}&source=${encodeURIComponent( | ||
| DEFAULT_TRACES_SOURCE_NAME, | ||
| )}&orderBy=${encodeURIComponent( | ||
| encodeURIComponent('Duration DESC, Timestamp DESC'), | ||
| )}`, | ||
| ); | ||
| await searchPage.table.waitForRowsToPopulate(); | ||
|
|
||
| expect(rowQuerySpansMs.length).toBeGreaterThan(0); | ||
| // A windowed query covers one narrow slice (1 to 15 minutes at first). | ||
| for (const span of rowQuerySpansMs) { | ||
| expect(span).toBeGreaterThanOrEqual(RANGE_MS - 1000); | ||
| } | ||
| }); | ||
| }, | ||
| ); |
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
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.