Skip to content

Commit

Permalink
[Rename] KQL to DQL (#37) (#187)
Browse files Browse the repository at this point in the history
Signed-off-by: Bishoy Boktor <boktorbb@amazon.com>
  • Loading branch information
boktorbb authored and mihirsoni committed Mar 20, 2021
1 parent 221bb31 commit 62cca9b
Show file tree
Hide file tree
Showing 55 changed files with 184 additions and 184 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-release-notes/src/release_notes_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export const AREAS: Area[] = [
'Feature:Filters',
'Feature:Timepicker',
'Feature:Highlight',
'Feature:KQL',
'Feature:DQL',
'Feature:Rollups',
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('Filter Utils', () => {
test('Empty string filters are ignored', () => {
expect(validateConvertFilterToKueryNode(['foo'], '', mockMappings)).toBeUndefined();
});
test('Validate a simple KQL KueryNode filter', () => {
test('Validate a simple DQL KueryNode filter', () => {
expect(
validateConvertFilterToKueryNode(
['foo'],
Expand All @@ -95,7 +95,7 @@ describe('Filter Utils', () => {
)
).toEqual(opensearchKuery.fromKueryExpression('foo.title: "best"'));
});
test('Validate a simple KQL expression filter', () => {
test('Validate a simple DQL expression filter', () => {
expect(
validateConvertFilterToKueryNode(['foo'], 'foo.attributes.title: "best"', mockMappings)
).toEqual(opensearchKuery.fromKueryExpression('foo.title: "best"'));
Expand Down
8 changes: 4 additions & 4 deletions src/core/server/saved_objects/service/lib/repository.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2673,7 +2673,7 @@ describe('SavedObjectsRepository', () => {
expect(client.search).not.toHaveBeenCalled();
});

it(`throws when KQL filter syntax is invalid`, async () => {
it(`throws when DQL filter syntax is invalid`, async () => {
const findOpts = {
namespaces: [namespace],
search: 'foo*',
Expand All @@ -2691,7 +2691,7 @@ describe('SavedObjectsRepository', () => {
};

await expect(savedObjectsRepository.find(findOpts)).rejects.toMatchInlineSnapshot(`
[Error: KQLSyntaxError: Expected "(", "{", value, whitespace but "<" found.
[Error: DQLSyntaxError: Expected "(", "{", value, whitespace but "<" found.
dashboard.attributes.otherField:<
--------------------------------^: Bad Request]
`);
Expand Down Expand Up @@ -2820,7 +2820,7 @@ describe('SavedObjectsRepository', () => {
});
});

it(`accepts KQL expression filter and passes KueryNode to getSearchDsl`, async () => {
it(`accepts DQL expression filter and passes KueryNode to getSearchDsl`, async () => {
const findOpts = {
namespaces: [namespace],
search: 'foo*',
Expand Down Expand Up @@ -2861,7 +2861,7 @@ describe('SavedObjectsRepository', () => {
`);
});

it(`accepts KQL KueryNode filter and passes KueryNode to getSearchDsl`, async () => {
it(`accepts DQL KueryNode filter and passes KueryNode to getSearchDsl`, async () => {
const findOpts = {
namespaces: [namespace],
search: 'foo*',
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/saved_objects/service/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,8 +768,8 @@ export class SavedObjectsRepository {
kueryNode = validateConvertFilterToKueryNode(allowedTypes, filter, this._mappings);
}
} catch (e) {
if (e.name === 'KQLSyntaxError') {
throw SavedObjectsErrorHelpers.createBadRequestError('KQLSyntaxError: ' + e.message);
if (e.name === 'DQLSyntaxError') {
throw SavedObjectsErrorHelpers.createBadRequestError('DQLSyntaxError: ' + e.message);
} else {
throw e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class ReplacePanelAction implements ActionByType<typeof ACTION_REPLACE_PA
if (!embeddable.parent || !isDashboard(embeddable.parent)) {
throw new IncompatibleActionError();
}
return 'kqlOperand';
return 'dqlOperand';
}

public async isCompatible({ embeddable }: ReplacePanelActionContext) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It is wired into the `TopNavMenu` component, but can be used independently.
### Fetch Query Suggestions

The `getQuerySuggestions` function helps to construct a query.
KQL suggestion functions are registered in X-Pack, so this API does not return results in OSS.
DQL suggestion functions are registered in X-Pack, so this API does not return results in OSS.

```.ts

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ describe('kuery AST API', () => {
expect(result).toEqual(true);
});

test('should return false for KQL ranges', () => {
test('should return false for DQL ranges', () => {
const result = doesKueryExpressionHaveLuceneSyntaxError('bar < 1');
expect(result).toEqual(false);
});
Expand All @@ -387,7 +387,7 @@ describe('kuery AST API', () => {
expect(result).toEqual(true);
});

test('should return false for KQL exists', () => {
test('should return false for DQL exists', () => {
const result = doesKueryExpressionHaveLuceneSyntaxError('bar:*');
expect(result).toEqual(false);
});
Expand All @@ -397,7 +397,7 @@ describe('kuery AST API', () => {
expect(result).toEqual(true);
});

test('should return false for KQL wildcards', () => {
test('should return false for DQL wildcards', () => {
const result = doesKueryExpressionHaveLuceneSyntaxError('bar: ba*');
expect(result).toEqual(false);
});
Expand Down Expand Up @@ -442,7 +442,7 @@ describe('kuery AST API', () => {
expect(result).toEqual(true);
});

test('should return true for mixed KQL/Lucene queries', () => {
test('should return true for mixed DQL/Lucene queries', () => {
const result = doesKueryExpressionHaveLuceneSyntaxError('foo: bar and (baz: qux || bag)');
expect(result).toEqual(true);
});
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data/common/opensearch_query/kuery/ast/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { nodeTypes } from '../node_types/index';
import { KQLSyntaxError } from '../kuery_syntax_error';
import { DQLSyntaxError } from '../kuery_syntax_error';
import { KueryNode, DslQuery, KueryParseOptions } from '../types';
import { IIndexPattern } from '../../../index_patterns/types';

Expand Down Expand Up @@ -60,7 +60,7 @@ export const fromKueryExpression = (
return fromExpression(expression, parseOptions, parseKuery);
} catch (error) {
if (error.name === 'SyntaxError') {
throw new KQLSyntaxError(error, expression);
throw new DQLSyntaxError(error, expression);
} else {
throw error;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ describe('getFullFieldNameNode', function () {
test('should throw an error if a path is provided for a non-nested field', () => {
const nameNode = nodeTypes.literal.buildNode('os');
expect(() => getFullFieldNameNode(nameNode, indexPattern, 'machine')).toThrowError(
/machine.os is not a nested field but is in nested group "machine" in the KQL expression/
/machine.os is not a nested field but is in nested group "machine" in the DQL expression/
);
});

test('should throw an error if a nested field is not passed with a path', () => {
const nameNode = nodeTypes.literal.buildNode('nestedField.child');

expect(() => getFullFieldNameNode(nameNode, indexPattern)).toThrowError(
/nestedField.child is a nested field, but is not in a nested group in the KQL expression./
/nestedField.child is a nested field, but is not in a nested group in the DQL expression./
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ export function getFullFieldNameNode(
if (nestedPath && !nestedPathFromField) {
return [
...acc,
`${field.name} is not a nested field but is in nested group "${nestedPath}" in the KQL expression.`,
`${field.name} is not a nested field but is in nested group "${nestedPath}" in the DQL expression.`,
];
}

if (nestedPathFromField && !nestedPath) {
return [
...acc,
`${field.name} is a nested field, but is not in a nested group in the KQL expression.`,
`${field.name} is a nested field, but is not in a nested group in the DQL expression.`,
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/common/opensearch_query/kuery/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

export { KQLSyntaxError } from './kuery_syntax_error';
export { DQLSyntaxError } from './kuery_syntax_error';
export { nodeTypes } from './node_types';
export * from './ast';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { fromKueryExpression } from './ast';

describe('kql syntax errors', () => {
describe('dql syntax errors', () => {
it('should throw an error for a field query missing a value', () => {
expect(() => {
fromKueryExpression('response:');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,39 @@
import { repeat } from 'lodash';
import { i18n } from '@osd/i18n';

const endOfInputText = i18n.translate('data.common.kql.errors.endOfInputText', {
const endOfInputText = i18n.translate('data.common.dql.errors.endOfInputText', {
defaultMessage: 'end of input',
});

const grammarRuleTranslations: Record<string, string> = {
fieldName: i18n.translate('data.common.kql.errors.fieldNameText', {
fieldName: i18n.translate('data.common.dql.errors.fieldNameText', {
defaultMessage: 'field name',
}),
value: i18n.translate('data.common.kql.errors.valueText', {
value: i18n.translate('data.common.dql.errors.valueText', {
defaultMessage: 'value',
}),
literal: i18n.translate('data.common.kql.errors.literalText', {
literal: i18n.translate('data.common.dql.errors.literalText', {
defaultMessage: 'literal',
}),
whitespace: i18n.translate('data.common.kql.errors.whitespaceText', {
whitespace: i18n.translate('data.common.dql.errors.whitespaceText', {
defaultMessage: 'whitespace',
}),
};

interface KQLSyntaxErrorData extends Error {
interface DQLSyntaxErrorData extends Error {
found: string;
expected: KQLSyntaxErrorExpected[] | null;
expected: DQLSyntaxErrorExpected[] | null;
location: any;
}

interface KQLSyntaxErrorExpected {
interface DQLSyntaxErrorExpected {
description: string;
}

export class KQLSyntaxError extends Error {
export class DQLSyntaxError extends Error {
shortMessage: string;

constructor(error: KQLSyntaxErrorData, expression: any) {
constructor(error: DQLSyntaxErrorData, expression: any) {
let message = error.message;
if (error.expected) {
const translatedExpectations = error.expected.map((expected) => {
Expand All @@ -61,7 +61,7 @@ export class KQLSyntaxError extends Error {

const translatedExpectationText = translatedExpectations.join(', ');

message = i18n.translate('data.common.kql.errors.syntaxError', {
message = i18n.translate('data.common.dql.errors.syntaxError', {
defaultMessage: 'Expected {expectedList} but {foundInput} found.',
values: {
expectedList: translatedExpectationText,
Expand All @@ -75,7 +75,7 @@ export class KQLSyntaxError extends Error {
);

super(fullMessage);
this.name = 'KQLSyntaxError';
this.name = 'DQLSyntaxError';
this.shortMessage = message;
}
}
6 changes: 3 additions & 3 deletions src/plugins/data/common/search/aggs/buckets/filters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ describe('Filters Agg', () => {
});
});

describe('using KQL', () => {
test('works with KQL filters', () => {
describe('using DQL', () => {
test('works with DQL filters', () => {
const aggConfigs = getAggConfigs({
filters: [
generateFilter('a', 'kuery', 'status:200'),
Expand Down Expand Up @@ -177,7 +177,7 @@ describe('Filters Agg', () => {
`);
});

test('works with KQL wildcards', () => {
test('works with DQL wildcards', () => {
const aggConfigs = getAggConfigs({
filters: [generateFilter('a', 'kuery', '*'), generateFilter('b', 'kuery', 'foo*')],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
}

// Uses the append style, but no bordering
.kqlQueryBar__languageSwitcherButton {
.dqlQueryBar__languageSwitcherButton {
border-right: none !important;
}

Expand Down
26 changes: 13 additions & 13 deletions src/plugins/data/public/ui/query_string_input/language_switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export function QueryLanguageSwitcher(props: Props) {
const luceneLabel = (
<FormattedMessage id="data.query.queryBar.luceneLanguageName" defaultMessage="Lucene" />
);
const kqlLabel = (
<FormattedMessage id="data.query.queryBar.kqlLanguageName" defaultMessage="KQL" />
const dqlLabel = (
<FormattedMessage id="data.query.queryBar.dqlLanguageName" defaultMessage="DQL" />
);
const kqlFullName = (
const dqlFullName = (
<FormattedMessage
id="data.query.queryBar.kqlFullLanguageName"
id="data.query.queryBar.dqlFullLanguageName"
defaultMessage="OpenSearch Dashboards Query Language"
/>
);
Expand All @@ -60,10 +60,10 @@ export function QueryLanguageSwitcher(props: Props) {
<EuiButtonEmpty
size="xs"
onClick={() => setIsPopoverOpen(!isPopoverOpen)}
className="euiFormControlLayout__append kqlQueryBar__languageSwitcherButton"
className="euiFormControlLayout__append dqlQueryBar__languageSwitcherButton"
data-test-subj={'switchQueryLanguageButton'}
>
{props.language === 'lucene' ? luceneLabel : kqlLabel}
{props.language === 'lucene' ? luceneLabel : dqlLabel}
</EuiButtonEmpty>
);

Expand All @@ -90,13 +90,13 @@ export function QueryLanguageSwitcher(props: Props) {
<p>
<FormattedMessage
id="data.query.queryBar.syntaxOptionsDescription"
defaultMessage="The {docsLink} (KQL) offers a simplified query
syntax and support for scripted fields. KQL also provides autocomplete if you have
a Basic license or above. If you turn off KQL, OpenSearch Dashboards uses Lucene."
defaultMessage="The {docsLink} (DQL) offers a simplified query
syntax and support for scripted fields. DQL also provides autocomplete if you have
a Basic license or above. If you turn off DQL, OpenSearch Dashboards uses Lucene."
values={{
docsLink: (
<EuiLink href={kueryQuerySyntaxDocs} target="_blank">
{kqlFullName}
{dqlFullName}
</EuiLink>
),
}}
Expand All @@ -107,15 +107,15 @@ export function QueryLanguageSwitcher(props: Props) {
<EuiSpacer size="m" />

<EuiForm>
<EuiFormRow label={kqlFullName}>
<EuiFormRow label={dqlFullName}>
<EuiSwitch
id="queryEnhancementOptIn"
name="popswitch"
label={
props.language === 'kuery' ? (
<FormattedMessage id="data.query.queryBar.kqlOnLabel" defaultMessage="On" />
<FormattedMessage id="data.query.queryBar.dqlOnLabel" defaultMessage="On" />
) : (
<FormattedMessage id="data.query.queryBar.kqlOffLabel" defaultMessage="Off" />
<FormattedMessage id="data.query.queryBar.dqlOffLabel" defaultMessage="Off" />
)
}
checked={props.language === 'kuery'}
Expand Down
Loading

0 comments on commit 62cca9b

Please sign in to comment.