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

Move convertDateTime, refactor query_utils #1064

Merged
merged 1 commit into from
Oct 4, 2023
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
161 changes: 0 additions & 161 deletions public/components/common/query_utils.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { parsePromQLIntoKeywords } from '../';

describe('Query Utils', () => {
describe('parsePromQLIntoKeywords', () => {
test('should parse plain catalog.metric into keywords', () => {
const query = 'catalog.metric';
const keywords = parsePromQLIntoKeywords(query);
expect(keywords).toEqual({
aggregation: 'avg',
attributesGroupBy: '',
connection: 'catalog',
metric: 'metric',
});
});

test('should parse simple ppl query_range into keywords', () => {
console.log('should parse simple ppl query_range into keywords');
const query = "source = test_catalog.query_range('metric')";
const keywords = parsePromQLIntoKeywords(query);
expect(keywords).toEqual({
aggregation: 'avg',
attributesGroupBy: '',
connection: 'test_catalog',
metric: 'metric',
});
});

test('should parse promql into keywords', () => {
console.log('should parse promql into keywords');
const query = "source = test_catalog.query_range('count by(one,two) (metric)')";
const keywords = parsePromQLIntoKeywords(query);
expect(keywords).toEqual({
aggregation: 'count',
attributesGroupBy: 'one,two',
connection: 'test_catalog',
metric: 'metric',
});
});
});
});
Loading
Loading