Skip to content
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

Web console: more robust durable storage setting detection #16493

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/operations/durable-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ Depending on the size of the results you're expecting, saving the final results

By default, Druid saves the final results for queries from deep storage to task reports. Generally, this is acceptable for smaller result sets but may lead to timeouts for larger result sets.

When you run a query, include the context parameter `selectDestination` and set it to `DURABLESTORAGE`:
When you run a query, include the context parameter `selectDestination` and set it to `durableStorage`:

```json
"context":{
...
"selectDestination": "DURABLESTORAGE"
"selectDestination": "durableStorage"
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import * as JSONBig from 'json-bigint-native';
import { v4 as uuidv4 } from 'uuid';

import type { RowColumn } from '../../utils';
import { deleteKeys } from '../../utils';
import { caseInsensitiveEquals, deleteKeys } from '../../utils';
import type { DruidEngine } from '../druid-engine/druid-engine';
import { validDruidEngine } from '../druid-engine/druid-engine';
import type { LastExecution } from '../execution/execution';
Expand Down Expand Up @@ -512,7 +512,11 @@ export class WorkbenchQuery {
}

const ingestQuery = this.isIngestQuery();
if (!unlimited && !ingestQuery && queryContext.selectDestination !== 'durableStorage') {
if (
!unlimited &&
!ingestQuery &&
!caseInsensitiveEquals(queryContext.selectDestination, 'durableStorage')
) {
apiQuery.context ||= {};
apiQuery.context.sqlOuterLimit = 1001;
}
Expand Down
11 changes: 11 additions & 0 deletions web-console/src/utils/general.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import {
arrangeWithPrefixSuffix,
caseInsensitiveEquals,
formatBytes,
formatBytesCompact,
formatInteger,
Expand Down Expand Up @@ -196,4 +197,14 @@ describe('general', () => {
});
});
});

describe('caseInsensitiveEquals', () => {
it('works', () => {
expect(caseInsensitiveEquals(undefined, undefined)).toEqual(true);
expect(caseInsensitiveEquals(undefined, 'x')).toEqual(false);
expect(caseInsensitiveEquals('x', undefined)).toEqual(false);
expect(caseInsensitiveEquals('x', 'X')).toEqual(true);
expect(caseInsensitiveEquals(undefined, '')).toEqual(false);
});
});
});
4 changes: 4 additions & 0 deletions web-console/src/utils/general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export function addOrUpdate<T>(xs: readonly T[], x: T, keyFn: (x: T) => string |

// ----------------------------

export function caseInsensitiveEquals(str1: string | undefined, str2: string | undefined): boolean {
return str1?.toLowerCase() === str2?.toLowerCase();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would throw a NPE if str1 or str2 are null, right? If yes, I think we should handle that as well since this is a utility function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no that is what the ? before the . is for. It is essentially doing (str1 ? str1.toLowerCase() : undefined) === (str2 ? str2.toLowerCase() : undefined). Added a test case so you can verify

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, thanks for the clarification!

}

export function caseInsensitiveContains(testString: string, searchString: string): boolean {
if (!searchString) return true;
return testString.toLowerCase().includes(searchString.toLowerCase());
Expand Down
Loading