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

Query manager #927

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2961e46
Bump prismjs from 1.25.0 to 1.27.0 in /dashboards-observability (#508…
opensearch-trigger-bot[bot] Mar 10, 2022
4afca56
change to support java 8 in compile and runtime (#575) (#576)
opensearch-trigger-bot[bot] Mar 11, 2022
c85b9ef
Add 1.3.0 release notes (#580) (#582)
opensearch-trigger-bot[bot] Mar 14, 2022
f1c410d
Merge branch '1.3' of github.com:opensearch-project/trace-analytics
mengweieric Mar 28, 2022
82db8c1
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Mar 29, 2022
ebcf5d4
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Mar 30, 2022
2dfd988
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Mar 31, 2022
9da1830
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Mar 31, 2022
41061dd
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Apr 4, 2022
b3c27d8
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Apr 6, 2022
ac027d9
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Apr 6, 2022
a4e104b
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Apr 6, 2022
988862b
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Apr 10, 2022
941607a
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Apr 12, 2022
ee3e67d
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Apr 13, 2022
e5f34fd
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Apr 13, 2022
92f959e
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Apr 15, 2022
e429b94
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Apr 18, 2022
e92691b
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Apr 19, 2022
4e09ce5
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Apr 19, 2022
70f3c04
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Apr 19, 2022
9c17d6b
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric May 11, 2022
c6daa2c
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric May 11, 2022
8fa87ed
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric May 15, 2022
b54de85
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric May 17, 2022
6034004
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Jun 24, 2022
9642f8c
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Jul 26, 2022
33000c2
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Aug 3, 2022
77082f6
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Aug 9, 2022
7bbc337
query manager
mengweieric Jul 26, 2022
d4126e9
removed aggregations from dimensions
mengweieric Jul 27, 2022
2a97f5b
qm improvements
mengweieric Aug 3, 2022
6da9701
types/code cleanups/error corrections
mengweieric Aug 3, 2022
5233543
fixed a undefined issue
mengweieric Aug 4, 2022
8f8cba2
qm fixes for query builder
mengweieric Aug 9, 2022
d20e21a
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Aug 10, 2022
d09c01f
merge backported changes for resolving build failures
mengweieric Aug 10, 2022
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
7 changes: 6 additions & 1 deletion dashboards-observability/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"test": "../../node_modules/.bin/jest --config ./test/jest.config.js",
"cypress:run": "TZ=America/Los_Angeles cypress run",
"cypress:open": "TZ=America/Los_Angeles cypress open",
"plugin_helpers": "node ../../scripts/plugin_helpers"
"plugin_helpers": "node ../../scripts/plugin_helpers",
"antlr4ts_ppl_lexer": "antlr4ts -visitor ./query_manager/grammar/OpenSearchPPLLexer.g4",
"antlr4ts_ppl_parser": "antlr4ts -visitor ./query_manager/grammar/OpenSearchPPLParser.g4"
},
"dependencies": {
"@algolia/autocomplete-core": "^1.4.1",
Expand All @@ -19,6 +21,8 @@
"@reduxjs/toolkit": "^1.6.1",
"ag-grid-community": "^27.3.0",
"ag-grid-react": "^27.3.0",
"antlr4": "4.8.0",
"antlr4ts": "^0.5.0-alpha.4",
"plotly.js-dist": "^2.2.0",
"react-graph-vis": "^1.0.5",
"react-paginate": "^8.1.3",
Expand All @@ -29,6 +33,7 @@
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/react-plotly.js": "^2.5.0",
"@types/react-test-renderer": "^16.9.1",
"antlr4ts-cli": "^0.5.0-alpha.4",
"cypress": "^5.0.0",
"eslint": "^6.8.0",
"jest-dom": "^4.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import { getVizContainerProps } from '../../visualizations/charts/helpers';
import { parseGetSuggestions, onItemSelect } from '../../common/search/autocomplete_logic';
import { formatError } from '../utils';
import { sleep } from '../../common/live_tail/live_tail_button';
import { QueryManager } from '../../../../query_manager/ppl_query_manager';

const TYPE_TAB_MAPPING = {
[SAVED_QUERY]: TAB_EVENT_ID,
Expand Down Expand Up @@ -806,27 +807,73 @@ export const Explorer = ({
);
};

const testAntlr = (query: string) => {
const qm = new QueryManager();
// const pplQueryBuilder = new PPLQueryBuilder();

// build query
const res =
qm
.queryBuilder()
.addSource('index')
.addPipe()
.addStats()
.addMetrics([
{
field: '',
agg_func: 'count'
},
{
field: 'bytes',
agg_func: 'avg',
alias: 'avg_bytes'
}
])
.addBy()
.addGroupBy([{
field: 'host'
},
{
field: 'tags'
}
])
.getQuery();

console.log('built res: ', res);

// parse query
const parsed_res =
qm
.queryParser()
.parse(query)
.getStats();

console.log('parsed res: ', parsed_res);

};

const handleQuerySearch = useCallback(
async (availability?: boolean) => {

// clear previous selected timestamp when index pattern changes
if (
!isEmpty(tempQuery) &&
!isEmpty(query[RAW_QUERY]) &&
isIndexPatternChanged(tempQuery, query[RAW_QUERY])
) {

await updateCurrentTimeStamp('');
}
if (availability !== true) {
await updateQueryInStore(tempQuery);
}
testAntlr(query[RAW_QUERY]);
fetchData();
},
[tempQuery, query[RAW_QUERY]]
);

const handleQueryChange = async (newQuery: string) => {
setTempQuery(newQuery);
};
const handleQueryChange = async (newQuery: string) => setTempQuery(newQuery);

const handleSavingObject = async () => {
const currQuery = queryRef.current;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,34 +201,36 @@ export const DataConfigPanelItem = ({ fieldOptionList, visualizations }: any) =>
</EuiTitle>
)}
<EuiPanel color="subdued" style={{ padding: '0px' }}>
{sectionName == 'metrics' && (
<EuiFormRow
label="Aggregation"
labelAppend={
visualizations.vis.name !== visChartTypes.HeatMap &&
lists.length !== 1 && (
<EuiText size="xs">
<EuiIcon
type="cross"
color="danger"
onClick={() => handleServiceRemove(index, sectionName)}
/>
</EuiText>
)
label="Aggregation"
labelAppend={
visualizations.vis.name !== visChartTypes.HeatMap &&
lists.length !== 1 && (
<EuiText size="xs">
<EuiIcon
type="cross"
color="danger"
onClick={() => handleServiceRemove(index, sectionName)}
/>
</EuiText>
)
}
>
<EuiComboBox
aria-label="Accessible screen reader label"
placeholder="Select a aggregation"
singleSelection={{ asPlainText: true }}
options={AGGREGATION_OPTIONS}
selectedOptions={
singleField.aggregation ? [{ label: singleField.aggregation }] : []
}
>
<EuiComboBox
aria-label="Accessible screen reader label"
placeholder="Select a aggregation"
singleSelection={{ asPlainText: true }}
options={AGGREGATION_OPTIONS}
selectedOptions={
singleField.aggregation ? [{ label: singleField.aggregation }] : []
}
onChange={(e) =>
updateList(e.length > 0 ? e[0].label : '', index, sectionName, 'aggregation')
}
/>
</EuiFormRow>
onChange={(e) =>
updateList(e.length > 0 ? e[0].label : '', index, sectionName, 'aggregation')
}
/>
</EuiFormRow>
)}
<EuiFormRow label="Field">
<EuiComboBox
aria-label="Accessible screen reader label"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { CharStream } from 'antlr4ts';

export class CaseInsensitiveCharStream {
private stream: CharStream;

get index(): number {
return this.stream.index;
}

get size(): number {
return this.stream.size;
}

get sourceName(): string {
return 'pplquery';
}

constructor(stream: CharStream) {
this.stream = stream;
}

LA(offset: number): number {
const c: number = this.stream.LA(offset);
if (c <= 0) {
return c;
}

// case insensitivity support for PPL
return String.fromCodePoint(c).toUpperCase().codePointAt(0)!;
}

consume(): void {
this.stream.consume();
}

mark(): number {
return this.stream.mark();
}

release(marker: number): void {
this.stream.release(marker);
}

seek(index: number): void {
this.stream.seek(index);
}

getText(interval: any): string {
return this.stream.getText(interval);
}

toString(): string {
return this.stream.toString();
}
}
Loading